Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Can I able to add query the table based on groupBy #74

Open
muhammedfayaz opened this issue Jul 15, 2022 · 0 comments
Open

Can I able to add query the table based on groupBy #74

muhammedfayaz opened this issue Jul 15, 2022 · 0 comments

Comments

@muhammedfayaz
Copy link

muhammedfayaz commented Jul 15, 2022

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);
    });`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant