Pass table collection to other blade
Is there a way to get the query or collection from the table and pass this on to a blade?
I have a action on the list page that needs this query/collection.
28 Replies
You should be able to call
$livewire->getTableQuery()
I think there a 2 more methods for query with filters and sortingAnd on what page does $livewire works?
All pages?
Is this good if I dd() $livewire?
Depends on where you use it. But in Closures the current page is injected as
$livewire
getTableQuery() is not found, hence why
If it's not a ListPage obviously there is no
getTableQuery()
🙈
Didn't realize you want that on a diferent page.Its a custom page with livewire component
And the Livewire component is the Table?
Yeah
Haven't really worked with LW v3 reactivity yet. Not sure whether and how you can access the child component.
Why is it a separate component though? Why not directly on the page?
Not sure actually
I thought i followed the documentation for this
If i only have a table and nothing else what would be the best way?
Make a resource?
Make a page and put the Livewire stuff in there.
Pages == LW components
Directly on the page?
Currently i have a filament page that has a view. In that view is the @livewire
Directly on the page.
Is there a documentation for that?
Why would you need a different documentation for it? It's the same thing.
I am so used to resources for tables and pages for custom livewire components that i probably didnt understand it right
I added the table() to the filament page but get the following error now:
Argument #1 ($table) must be of type Filament\Tables\Table, Filament\Infolists\Infolist given
Imported is Filament\Tables\Table;
Can you share the page code?
Not sure why it's trying to pass an Infolist, but you didn't add the traits.
I didnt understand that either
From the looks of it I dont see anything wrong
Is this the right way to add the table to a page?
It mentions
Whoops
Had those in the livewire component
But didnt add it to the filament page
$livewire->getTableQuery()
being null is normal i guess?I guess, as this was the way to define it in v2. You can probably access the query via the table directly. Something like
$livewire->table->getQuery() ?!
Thanks. Everything works fine now!
What was the final code?
To make the table work all it needed was the Contracts and Concerns
For the query i did some stuff with
->toSql
so i can copy the query
I couldnt get it to work to get the query from $livewire
. So i just copied the ->query()
function from the $table