F
Filamentβ€’5mo 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 Kochβ€’5mo ago
You should be able to call $livewire->getTableQuery() I think there a 2 more methods for query with filters and sorting
Thijmen
Thijmenβ€’5mo ago
And on what page does $livewire works? All pages?
Thijmen
Thijmenβ€’5mo ago
Is this good if I dd() $livewire?
No description
Dennis Koch
Dennis Kochβ€’5mo ago
Depends on where you use it. But in Closures the current page is injected as $livewire
Thijmen
Thijmenβ€’5mo ago
getTableQuery() is not found, hence why
Dennis Koch
Dennis Kochβ€’5mo ago
If it's not a ListPage obviously there is no getTableQuery() πŸ™ˆ Didn't realize you want that on a diferent page.
Thijmen
Thijmenβ€’5mo ago
Its a custom page with livewire component
Dennis Koch
Dennis Kochβ€’5mo ago
And the Livewire component is the Table?
Thijmen
Thijmenβ€’5mo 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 Kochβ€’5mo 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
Thijmenβ€’5mo 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 Kochβ€’5mo ago
Make a page and put the Livewire stuff in there. Pages == LW components
Thijmen
Thijmenβ€’5mo ago
Directly on the page? Currently i have a filament page that has a view. In that view is the @livewire
Dennis Koch
Dennis Kochβ€’5mo ago
Directly on the page.
Thijmen
Thijmenβ€’5mo ago
Is there a documentation for that?
Dennis Koch
Dennis Kochβ€’5mo ago
Why would you need a different documentation for it? It's the same thing.
Thijmen
Thijmenβ€’5mo 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 Kochβ€’5mo ago
Can you share the page code?
Thijmen
Thijmenβ€’5mo ago
Gist
Replenish.php
GitHub Gist: instantly share code, notes, and snippets.
Dennis Koch
Dennis Kochβ€’5mo ago
Not sure why it's trying to pass an Infolist, but you didn't add the traits.
Thijmen
Thijmenβ€’5mo 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 Kochβ€’5mo ago
It mentions
use InteractsWithTable;
use InteractsWithForms;
use InteractsWithTable;
use InteractsWithForms;
Thijmen
Thijmenβ€’5mo 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 Kochβ€’5mo 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
Thijmenβ€’5mo ago
Thanks. Everything works fine now!
Dennis Koch
Dennis Kochβ€’5mo ago
What was the final code?
Thijmen
Thijmenβ€’5mo 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
More Posts