Filter Relation Manager records by Query string parameter
I have a Edit page with a relation manager I want to filter the records in relation manager based on a value given in the query string. I notice that I can't access from here, but I can from the Edit Page. Any idea?
8 Replies
i don't understand the question
You can probably pass the param to the page (which is a Livewire component) and then access it via
$livewire->your_property
from the RM (depending on where you need it)thanks @Dennis Koch
let's say I have an EditAccount Page
which I can set a property and initialize it in the mount method with the query parameter, here all ok
then I have a TransactionsRelationManager
How can I access the EditAccount->platform_id property from the TransactionsRelationManager?
I don't find a way to access the parent component, let's say.
You have access to
$this->getOwnerRecord()
in your TransactionsRelationManager
Resource
$this->getOwnerRecord()
will get the parent of the Relationship which is a model
so you should be able to access like $this->getOwnerRecord()->platform_id
@Will 🇬🇹
thanks!
but in this case I want to access a property of the parent component, not precisely the Model.
If you have an inverse relationship then you could just get it off the transaction record, right?
transaction->account->platform_id
You need to communicate between the components via Livewire events.
@awcodes not that easy
let's say
the EditAccount shows an Account that has transactions of different platforms
I want to take advantage of this view to filter the transactions given a platform_id via the query string
@Dennis Koch
thanks!
at the end I ended up saving the query string parameter in the EditAccount page.
then when relation manager is loaded, it requests the platformId value from the EditAccount, the EditAccount dispatch the value, then the RM receives it and that's it!
Thanks!