Skip to content
This repository was archived by the owner on Jun 27, 2024. It is now read-only.
This repository was 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

Description

@muhammedfayaz

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);
    });`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions