F
Filament11mo ago
Thijmen

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
Dennis Koch
Dennis Koch11mo ago
You should be able to call $livewire->getTableQuery() I think there a 2 more methods for query with filters and sorting
Thijmen
ThijmenOP11mo ago
And on what page does $livewire works? All pages?
Thijmen
ThijmenOP11mo ago
Is this good if I dd() $livewire?
No description
Dennis Koch
Dennis Koch11mo ago
Depends on where you use it. But in Closures the current page is injected as $livewire
Thijmen
ThijmenOP11mo ago
getTableQuery() is not found, hence why
Dennis Koch
Dennis Koch11mo ago
If it's not a ListPage obviously there is no getTableQuery() 🙈 Didn't realize you want that on a diferent page.
Thijmen
ThijmenOP11mo ago
Its a custom page with livewire component
Dennis Koch
Dennis Koch11mo ago
And the Livewire component is the Table?
Thijmen
ThijmenOP11mo ago
Yeah
<x-filament-panels::page>
@livewire('replenish')
</x-filament-panels::page>
<x-filament-panels::page>
@livewire('replenish')
</x-filament-panels::page>
Dennis Koch
Dennis Koch11mo ago
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?
Thijmen
ThijmenOP11mo ago
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?
Dennis Koch
Dennis Koch11mo ago
Make a page and put the Livewire stuff in there. Pages == LW components
Thijmen
ThijmenOP11mo ago
Directly on the page? Currently i have a filament page that has a view. In that view is the @livewire
Dennis Koch
Dennis Koch11mo ago
Directly on the page.
Thijmen
ThijmenOP11mo ago
Is there a documentation for that?
Dennis Koch
Dennis Koch11mo ago
Why would you need a different documentation for it? It's the same thing.
Thijmen
ThijmenOP11mo ago
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;
Dennis Koch
Dennis Koch11mo ago
Can you share the page code?
Thijmen
ThijmenOP11mo ago
Gist
Replenish.php
GitHub Gist: instantly share code, notes, and snippets.
Dennis Koch
Dennis Koch11mo ago
Not sure why it's trying to pass an Infolist, but you didn't add the traits.
Thijmen
ThijmenOP11mo ago
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?
Dennis Koch
Dennis Koch11mo ago
It mentions
use InteractsWithTable;
use InteractsWithForms;
use InteractsWithTable;
use InteractsWithForms;
Thijmen
ThijmenOP11mo ago
Whoops Had those in the livewire component But didnt add it to the filament page $livewire->getTableQuery() being null is normal i guess?
Dennis Koch
Dennis Koch11mo ago
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() ?!
Thijmen
ThijmenOP11mo ago
Thanks. Everything works fine now!
Dennis Koch
Dennis Koch11mo ago
What was the final code?
Thijmen
ThijmenOP11mo ago
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
Want results from more Discord servers?
Add your server