FilamentF
Filament2y ago
19 replies
Marc

Unnecessary SQL in select filter using relations

I am using SelectFilter with preload, when the page loads the SQL is being executed, but the select does not show any data, so, every time you click on the select, it makes another call to the server and performs another SQL query, the same as the previous one.

Is there any way to avoid it?
SelectFilter::make('roles')->label(__('Roles'))->preload()->multiple()->relationship('roles', 'name');


select distinct `roles`.* from `roles` left join `model_has_roles` on `roles`.`id` = `model_has_roles`.`role_id` order by `roles`.`name` asc
Was this page helpful?