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
Dhru
Dhru5mo ago
i don't understand the question
Dennis Koch
Dennis Koch5mo ago
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)
Francisco García
Francisco GarcíaOP5mo ago
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.
Will Aguilar
Will Aguilar5mo ago
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
Francisco García
Francisco GarcíaOP5mo ago
@Will 🇬🇹 thanks! but in this case I want to access a property of the parent component, not precisely the Model.
awcodes
awcodes5mo ago
If you have an inverse relationship then you could just get it off the transaction record, right? transaction->account->platform_id
Dennis Koch
Dennis Koch5mo ago
You need to communicate between the components via Livewire events.
Francisco García
Francisco GarcíaOP5mo ago
@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!

Did you find this page helpful?