platform
platform copied to clipboard
Configure Relation search query
https://github.com/orchidsoftware/platform/blob/8b68fcb2571a302135f21f3a987434d8959f804e/src/Platform/Http/Controllers/Systems/RelationController.php#L85
It would be nice to have a bit more flexibility on this query.
in my case I would like to use ILIKE (Postgres)
it's possible to use scope but the $search parameter is not passed to the scope.
maybe we can add something like filterWithScope on the Relation field and call it with
$model = $model->{$filterScope['name']}(...array_merge($filterScope['parameters'] ?? [], $search));
What do you think of such a non-database solution:
$search = mb_strtolower($search);
$query->whereRaw("LOWER({$property}) LIKE ?", ["%{$search}%"]);
This could fix my issue. I believe Scopes are more flexible and more future-proof.
I have nothing against your suggestion. Would you like to prepare a PR?
But you also need to consider other columns: https://github.com/orchidsoftware/platform/blob/8b68fcb2571a302135f21f3a987434d8959f804e/src/Platform/Http/Controllers/Systems/RelationController.php#L89