Advice for code & structure
Hi!
I'm currently developing my first app using Filament. My experience primarily lies in working with Laravel for smaller applications within startups and companies, where I focused on automating processes.
Recently, I decided to create a SaaS application using Laravel and discovered Filament in my research. I've been experimenting with Filament and have started integrating it into my SaaS boilerplate, particularly for core user panel functions like teams, roles, permissions, plugins, user/admin panels, and payment methods.
I've completed the Teams feature and its corresponding views in the admin panel. However, I'm unsure if I'm utilizing Filament optimally and have some questions. I would appreciate insights from experienced programmers:
1. Is it advisable to use Filament for an entire project? I find it very useful and want to incorporate it fully into my product. Are there potential issues with this approach, such as handling payments?
2. Many developers seem to prefer custom Livewire components over resources for their models. Why is this?
3. In what situations should custom Livewire components be used instead of resources? Can you provide an example?
4. My TeamResource has 227 lines, including multiple functions like form, table, infolist, and some configurations. These seem like separate aspects of the same model, which makes me wonder if it's too much for one class. When should a class be split into smaller ones for cleaner code?
Or is this just the way how Filament should be used?
3 Replies
Hey, is there anyone who knows the answers to my questions?
Basically the answers to all of your questions is that it depends on the app. There is no silver bullet, one size fits all solution. Welcome to developing.
If you’re doing a SaaS then yes, filament can do that. If you just need Filament to serve as a CMS, yes it can do that too. Questions 2-4, depends on personally preference and there is no right or wrong answer/approach.
1. Filament shouldn't be an issue when it comes to payments. You need to ask yourself whether you could build your SAAS in the style of Filament with the given layout and keep in mind that there might be changes in the future.
2. Custom LW components make sense, when the defaults aren't enough, like when you need more functionality or a different design.
3. See above. More functionality. E.g. I built #pxlrbt-activity-log which shows the changes on a model. It's a custom page/LW component.
4. There is no fixes rule. Whenever you feel like it. If you have separate view/edit or only edit view, you could also move the form to the EditPage and the table to the ListPage. Or you can create a class that just returns the table/form schema. This is up to your and there is no fixed rule on how to do this.