🤖transistor🤖
Button to create model in other resources
if your models are related and it's not too complicated (too many fields or complex conditions), you could do something like this:
https://filamentphp.com/docs/3.x/panels/resources/relation-managers#creating-related-records
If you want to create a different model (not related) you could create a Filament action, something like this:
if you need more data than the model, you can inject
Get
or the livewire instance.
Then in your Laravel app, create an Action
directory and create an action:
6 replies
Best way to determine which resource a select component is currently being rendered on
To access the owner record you need to inject the livewire instance like so:
https://filamentphp.com/docs/3.x/panels/resources/relation-managers#accessing-the-relationships-owner-record
so, if I understand correctly,
Select::make('role_id')
options depend on whether it is loaded under SchoolResource
or ProgramResource
, right?
I would test the owner record to see if it contains a value from the parent resource to determine which options to load. Does this make sense?4 replies
getFormActions / getCreateFormAction - Need to customize the save button to add more functionality
have you checked the Customizing the creation process in the docs? https://filamentphp.com/docs/3.x/panels/resources/creating-records#customizing-the-creation-process
also check the Lifecycle hooks in that same page.
If that doesn't cover you needs, then you need to create a Laravel Action, not a Filament action, there you will handle everything about your saving process and then maybe remove the default save button and replace it with your own, so that it invokes your action. Does this help?
4 replies
Resource table with date granularity
you seem to be looking for a db design, check this out (skip to the Hotels and rooms section) https://vertabelo.com/blog/a-database-model-for-a-hotel-reservation-booking-app-and-channel-manager/
no affiliation, just found it in my bookmarks
4 replies
Dynamic form for a products attributes
One important thing is missing from your post, are you editing or creating a new record?
Becuase the
default
property won't work on edit, only on create.
If that's your case, you want to use the afterStateHydrated
and inject your component and model record so you do something like this:
what throws me off is your loop, have you looked into Relation Managers?
https://filamentphp.com/docs/3.x/panels/resources/relation-managers3 replies
Got Problem in Relation Table Column
ok, it looks like it's confusing the
author
property (which is the author id, right?) and the author
relationship.
try changing your relation to something different, like public function author_model(): BelongsTo
or anything different from author
and the use that as the relationship name.16 replies
custom action button can be used in multiple places
@Np you might find this helpful
https://gist.github.com/jlpellicer/ee8fb0f2b040a8e966cde64fe115eaa8#file-new_action-md
22 replies