F
Filament16mo ago
Connor

hasMany relationship in form?

So i'm essentially looking to build something like the example found in the demo.. I have a "Leads" model, which hasMany "Jobs". I would like when i click a lead, it shows below any related jobs like in the attached picture.. Apologise if this is well documented and I'm just missing it completely, but I'm struggling to get my head around a few of the bigger concepts of filament currently.. If someone could point out what part of the doc or point me to where I can configure this, I would very much appreciate it!
No description
3 Replies
krekas
krekas16mo ago
this is called relation manager also the code for demo is open source
cheesegrits
cheesegrits16mo ago
Here's the section of the docs you need. In your case, assuming you have already created a LeadsResource (using the "make:filament-resource LeadsResource" artisan command), the magic Artisan incantation to create the jobs relation manager (RM) on the LeadsResource would be something like:
php artisan make:filament-relation-manager LeadsResource jobs job_title
php artisan make:filament-relation-manager LeadsResource jobs job_title
Obviously change your resource name (LeadsResource), relationship (jobs) and title attribute (job_title) to suite. Then follow the instructions the command gives you to add that RM to the LeadsResource. If you want Filament to also have its best guess at filling in all the columns and form fields for you, you can add the --generate flag https://filamentphp.com/docs/3.x/panels/resources/relation-managers#creating-a-relation-manager
Connor
ConnorOP16mo ago
Thanks a bunch guys, appreciate it!
Want results from more Discord servers?
Add your server