Error table query for table widget
I have this query that i use to group data per day. To calculate the total of a vehicle per day.
I initially tried creating a table widget with this query and I got an error (image 2). But when I tried it on a custom page that implements hasTable with InteractsWithTable the same query worked. Could anyone help?
26 Replies
?
you cant group in eloquent queries
it fucks up the model hydration
because of that, you cant properly group in filament tables
So there is no way to achieve grouping?
in v3 there is row grouping feature with column totals but not in v2. it would need to be a custom livewire component / view instead of the table builder
Alright, I'll make a custom component.
Another question, is it possible to pass data from a selected record to a widget on the same page? If yes, how?
is it a custom page?
yes
Basically I have a table where you can select a vehicle and then the widget shows additional information for that specific record id.
GitHub
How to pass variable to Stats overview and chart widgets · filament...
I want to display stats overview or chart inside detail (custom) page, but I need to check data base on that particular $id Any suggestion to pass ID to the widgets and access that ID in another cl...
Is there like a line of code to set the record. Something like $this->record = something? Or am I getting the wrong idea?
if you just define
public $record
in the widget, it will be filled by livewire from that arrayalright and to set the value what do i use? Since a custom page doesnt have a record by default
the contents of the widget-data array will be matched up to properties of the same name on the widget
inside the page view, you can access the current livewire component with $this or all public properties as variables
you could extend the ViewRecord page class if you want which will add a $record property that gets autofilled for you from the url
I added the widget data line in the blade file of my custom page. But my custom widget still has $record returning null.
show me the code in the 3 files
Widget blade file
try extending the ViewRecord class instead of Page, then remove the $record property on that class
This is the concept i am going for but ill try the viewrecord class
since the custom page doesn't have a record selected yet. I believe viewrecord wouldn't work.
The widget below serve to show additonal information based on the selected vehicle next to the information displayed in the first table
so where are you setting the record on the page
viewrecord assumes that the record is in the url
just like setting a property
does the widget aswell?
where is this
the widget recieves data from the widget-data which is passed from the page
CustomPage.php file
which method
because it needs to be in mount() because after the page loads the widget wont recieve new data
if the widget needs to recieve data after the page loads, you need to use a Livewire event instead
Hmm I see!