FilamentF
Filament10mo ago
fpolli

Table row grouping oddness

I am grouping rows by a field and a related field like so:
use Illuminate\Database\Eloquent\Builder;
return $table
      ->recordTitleAttribute('name')
      ->groups([
        Group::make('the_type')
        ->groupQueryUsing(fn (Builder $query) => $query->groupBy('the_type','user.initials'))

This works and groups the rows the way I want. Note it accepts an Eloquent Builder.

When I try to put a summarizer on one of the columns, however, it sends a Database\Query\Builder to the groupUsingQuery instead of an Eloquent Builder and throws an error. If I change the groupQueryUsing method to accept a Database Builder, it does not properly craft the SQL to include the users table for the users.initials field and throws an error.
Was this page helpful?