Hi everyone,
I'm evaluating an architectural decision in my Laravel 12 project.
I have a page that displays filters configurable on three levels:
- from config file: full list of available filters
- from DB per company: each company decides which filters to use and in what order
- from DB per user: each user enables/disables/moves filters via the UI
The ModuleConfigService generates the final $filters array.
Solution 1 (Controller):
The controller uses the service to get $filters and $options, and passes them to the view:
Solution 2 (Component):
The controller only passes $options. The component gets the module from the route and uses the service to retrieve $filters.
Advantages of Solution 2: less boilerplate, centralized logic in the component.
Concerns: risk of making the component too coupled and harder to test.
In reality, the same logic is repeated for other arrays (fields, tabs, etc.), so I’d like to avoid duplication in controllers.
How do you handle this kind of situation? Do you prefer passing everything from the controller or delegating to the component?
Thanks!