Modify query in Resource if not searching
Hey all, I am trying to only include top level pages on a PageResource by modifying the eloquent query on the PageResource. You can then access child pages via a PageRelationshipManager. However if a user searches, I want to include the child pages in the PageResource search result. My code is below:
This works if you refresh the page as request('tableSearch') returns the seaerch query. But if you just search and let livewire do the ajax search, request('tableSearch') returns null.
Any ideas? Thanks
Solution:Jump to solution
I was able to do it by implementing the table method on the ListPages class.
```php
public function table(Table $table): Table
{
return static::getResource()::table($table)...
3 Replies
request('tableSearch') returns nullYou should access stuff via the Livewire component and not via
request()
when working with LivewireThanks. I'm not sure how I can access the livewire component though, as I'm inside a static method and nothing is passed to it?
Solution
I was able to do it by implementing the table method on the ListPages class.