Place table Widgets under tabs on custom view page

I want the invoice table to be under the invoice tab .Receipts will have it's table and so on for the tabs.In my code , i created the table as a widget and added it inside getFooterWidgets() just to ensure it displays .the intention is not for the table to be a footer.
16 Replies
Patrick Boivin
@lodeki How did you create the tabs? Is this a custom page?
lodeki
lodekiOP2y ago
Yes ....the tabs are the normal tailwind with html.
Patrick Boivin
Ok, makes sense. Your widgets are simple Livewire components so if you have one widget for each table you want, you can display each table inside of its own Tab.
lodeki
lodekiOP2y ago
Okay let me try it out then i'll get back .
Patrick Boivin
I think something like this should work:
@livewire(\Livewire\Livewire::getAlias(MyWidget::class), [ /* widget data */ ])
@livewire(\Livewire\Livewire::getAlias(MyWidget::class), [ /* widget data */ ])
lodeki
lodekiOP2y ago
That one didn't work . I got Unable to find component: [] even after running livewire:discover command .
Thijmen
Thijmen2y ago
Make a component for every table you are going to use
Thijmen
Thijmen2y ago
You can render the livewire component you made for this table in your blade with the tabs
lodeki
lodekiOP2y ago
Thank you .Let me try it . It really worked .Thank you .The only challenge i have is to get the $record so that i can use it in the getTableQuery() method .
Thijmen
Thijmen2y ago
Where do you need the record for in the query?
lodeki
lodekiOP2y ago
Inside the component, I have the getTableQuery() function that returns a Builder .I want to use the record in this method .
Thijmen
Thijmen2y ago
I don't think you are supposed to use record in the Query. Because query is supposed to get all records Also the record doesn't exist there because you haven't selected 1 record You could do a Model::where and get all the record data from there
lodeki
lodekiOP2y ago
I passed the $record to the component this way * @livewire('invoices-table-component',['record' => $this->record]) * .When i dd($record) inside the mount method of the component i get the record.
Thijmen
Thijmen2y ago
Why do you want to get the record? You get only a table with 1 record in it then?
lodeki
lodekiOP2y ago
The invoice table has invoices related to that particular record,that's why i had to use the record to query the invoices related to it.
Want results from more Discord servers?
Add your server