Query string null in a relationmanager
I can read
request()->query('group')
in ViewUser::getTitle
just fine but in UserResource's ResultsRelationManager it returns null.
Is there a way to read URL query strings in a relationmanager, or some other way to pass data from Resource to Relationmanager? I need to alter both UserResource infolist and the ResultsRelationManager table under it based on this query string. π€Solution:Jump to solution
in your relation manager if you would add property $group and set it as Url livewire attribute. does it work then?
```php
use Livewire\Attributes\Url;
#[Url]...
10 Replies
what's this group is in url? where it comes from?
Better to create a custom resource pageπ
still curious what is that group, where it comes from and what you are trying to do
Filter relationmanager rows by two columns, User and Group. So $record would be User but then I need to also pass Group so I need to pass that by query string in URL, for example
UserResource::getUrl('view', ['record' => $record, 'group_id' => $group->id])
does group belong to the record?
belongstomany
you could maybe get group from a owner record
Solution
in your relation manager if you would add property $group and set it as Url livewire attribute. does it work then?
and call it where needed like
$this->group
thenHey! Yeah i did something like that. Setting group as a property worked and also helped debug another problem I had, this time with custom pages π
https://discord.com/channels/883083792112300104/1327240818855252000/1327250122551201852
Using
#[Url]
to optimize line count further might be a good idea π