How to Structure Code for Filament Modules in Livewire?
I am using all Filament modules in Livewire directly, not the Panel Builder. My goal to make the main component cleaner and lighter by breaking down functionality into smaller parts. Here are the two approaches I am considering:
Approach 1: Using Traits
- Break down actions and forms into traits to keep the main Livewire component focused on its primary responsibilities.
- The traits encapsulate logic related to actions and forms for better code clarity.
File Structure: --- Approach 2: Using Classes - Encapsulate each action and bulk action into its own class for better organization.
- The classes are grouped logically in directories to separate concerns and keep the main component light.
File Structure: Which approach is more used in the filament Community
- The traits encapsulate logic related to actions and forms for better code clarity.
File Structure: --- Approach 2: Using Classes - Encapsulate each action and bulk action into its own class for better organization.
- The classes are grouped logically in directories to separate concerns and keep the main component light.
File Structure: Which approach is more used in the filament Community
1 Reply
code example for using a class
depending on the action i can also include the edit form inside the class since it part of the edit action but in some case where both the edit and create from is the same i just put inside the model so both class can access it
this is how my index compoent look like regradless of the apporch