Livewire Component within tabs in Resource View
Hi
I have an Infolist Builder, and within it, I ahve created some tabs. Now, I've worked out how to get a Livewire Component to render some content to one of the tabs, but what I would like is for that Livewire Component to display related objects.
I am also able to do that, but rather than showing objects related to the Resource I'm viewing, it shows ALL (in my component I have
I am also able to do that, but rather than showing objects related to the Resource I'm viewing, it shows ALL (in my component I have
$table->query(Related::query())
so that doesn't really surprise me that it does that.
What I would like to know is how I can get the parent Resource model/ID in the Component to be able to alter the query method to only return related modelsSolution:Jump to solution
perhaps:
then in ListVIPs class, define customer public property to use it in ur query or elsewhere....
4 Replies
@sdousley can u show the code where u call/render the livewire component?
Sorry, yes, I should have included that, so in
App\Filamenet\Resources\CustomerResource
I have the infolist method, and in that, i have:
ListVIPs is the Livewire component, which has the table method to display the results, I'm guessing I just need some way to filter in the ->query() method, but that's where I'm unsure
Or if there's a better way of doing this, I'm more than open to other suggestionsSolution
perhaps:
then in ListVIPs class, define customer public property to use it in ur query or elsewhere.
refer to this: https://filamentphp.com/docs/3.x/infolists/advanced#passing-parameters-to-a-livewire-component
OK yes, that gets the customer into the Livewire Component, it was the
$infolist->getRecord()
that I was missing.
I have, however, since found that by adding the RelationsManagers for models and defining the code in the view customer blade template to show the relations, that actually works as I was trying to make work with the tabs. Plus being more natively filament, is probably better
Either way, I will mark the above as the solution, as it actually answered my question thanks @KeyMe