TableWidget with morphTo and groupedBy
I have a Eloquent model
The morphTo goes (for now) only to the
For this, I wanna create a widget to show the most clicked elements, with the name and the counted number of
| name | count |
|-----------|-------|
| Product 3 | 44 |
| Product 1 | 32 |
| Product 2 | 18 |
To get this, I would write:
The problem is, that a table widgets
This shows me the table with a list of all clicks, by the name of the related product. But how to group now after product.id and get the count?
Any ideas?
StatisticsClick with the following columns:- id
- model_type
- model_id
- created_at
The morphTo goes (for now) only to the
Product model.For this, I wanna create a widget to show the most clicked elements, with the name and the counted number of
StatisticsClick entries. Something like this result:| name | count |
|-----------|-------|
| Product 3 | 44 |
| Product 1 | 32 |
| Product 2 | 18 |
To get this, I would write:
The problem is, that a table widgets
getTableQuery only accept Illuminate\Database\Eloquent\Builderas return values and no Illuminate\Database\Query\Builder. This is my starting point:This shows me the table with a list of all clicks, by the name of the related product. But how to group now after product.id and get the count?
Any ideas?