Open muhammedfayaz opened 2 years ago
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); });`
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}%"); }); });