Custom Reports using Filament Tables
I am trying to create views for reports. And in these view I am trying to load filament table with the report data.
I tried creating a filament-page and load table but not able to do so due to the error Property [$table] not found on component:...
19 Replies
It's a page so it won't have a table. Please read the table docs on how to add the table.
"I tried creating a filament-page and load table but not able to do so due to the error Property [$table] not found on component:"
Like I said in other post, If you're going to do like this then you need to follow this https://filamentphp.com/docs/2.x/tables/getting-started#preparing-your-livewire-component
Okk! I loaded a form in a page so I assumed I can do the same for table too. My Bad.
I did this using livewire as suggested and I am able to load table. Is there a way I can bring the side nav bar too? My view looks pretty bad without the headers and navbar.
Send code please, it shouldn't break anything normally
Did you create your page using this https://filamentphp.com/docs/2.x/admin/pages/getting-started#creating-a-page
The view is:
<div>
{{ $this->table }}
</div>
class should extend 'Page' not component.. did you use this to create your page?
Creating page didn't work. So I created a livewire component instead using artisal make:livewire.
You can do the same for the table, but I am assuming you didnt
Can you provide the whole page code
The view is:
<div>
{{ $this->table }}
</div>
Flare
Property [$table] not found on component: [app.filament.pages.flavour-report] - The error occurred at http://backend.test/admin/flavour-report
@toeknee_iom This is the full code with error.
So as per their error, you have not implemented tables.
try:
Thanks @toeknee_iom . I was expecting that it won't require this as it does not require with form when building a filament page.
I am able to show flavors here. Awesome!
One last thing I want to achieve here is show a report (generated using many tables) instead of Flavor model.
Here my $data variable is an array that I want to load as filament table like we would do using foreach().. in vanilla laravel blade.
$report = (new ReportDashboardController)->cakeFlavorProduction(new Request());
$data = json_decode($report->getContent(), true)['data'];
Is this possible?
You can't manipulate tables data, you have to use the native render. However, you can use sushi and create a custom model to get the data instead of a model as per your request if I understand it correctly.
Got it! I think I can manipulate the table using a unique identifier for the eloquent model that I am using and fetching the row of data for that identifier using formatStateUsing.
Thanks a tons @toeknee_iom @.valpuia You're a life saver!
Great stuff! welcomes
Here's the code:
hi friend i would love to see how you didi this can u show more code like the view and also the controller please help me
i want to show an array of data to show in the table