platform icon indicating copy to clipboard operation
platform copied to clipboard

Configure Relation search query

Open G3z opened this issue 4 years ago • 3 comments

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));

G3z avatar Dec 07 '20 09:12 G3z

What do you think of such a non-database solution:



$search = mb_strtolower($search);

$query->whereRaw("LOWER({$property}) LIKE ?", ["%{$search}%"]);

tabuna avatar Dec 07 '20 12:12 tabuna

This could fix my issue. I believe Scopes are more flexible and more future-proof.

G3z avatar Dec 07 '20 12:12 G3z

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

tabuna avatar Dec 07 '20 12:12 tabuna