inertiajs-tables-laravel-query-builder
inertiajs-tables-laravel-query-builder copied to clipboard
Can I able to add query the table based on groupBy
I need to create a table based on groupby, count it based on the value and show it in the table
` $globalSearch = AllowedFilter::callback('global', function ($query, $value) { $query->where(function ($query) use ($value) { $query->orWhere('term', 'LIKE', "%{$value}%"); }); });
$activities = QueryBuilder::for(Activity::select('term', DB::raw('count(*) as total'))
->groupBy('term'))
->defaultSort('term')
->allowedSorts(['term'])
->allowedFilters(['term', $globalSearch])
->paginate()
->withQueryString();
return Inertia::render('Dashboard', [
'activities' => $activities,
])->table(function (InertiaTable $table) {
$table->withGlobalSearch()
->defaultSort('term')
->column(key: 'term', searchable: true, sortable: true, canBeHidden: false);
});`