platform icon indicating copy to clipboard operation
platform copied to clipboard

[13.0] Shorten Filters

Open tabuna opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe.

It seems strange to me to specify HTTP filters and Eloquent filter separately, for example:

public function query(): iterable
{
    return [
        'users' => User::with('roles')
            ->filters(UserFiltersLayout::class)
            ->filtersApplySelection(UserFiltersLayout::class)
            ->defaultSort('id', 'desc')
            ->paginate(),
    ];
}

Describe the solution you'd like

We could use an argument to automatically call it later inside the class:

public function query(): iterable
{
    return [
        'users' => User::with('roles')
            ->filters(UserFiltersLayout::class)
            ->defaultSort('id', 'desc')
            ->paginate(),
    ];
}

Additional context

I find the risk of current and future problems very small. This will also work with passing a separate array with filters:

public function query(): iterable
{
    return [
        'users' => User::with('roles')
            ->filters([
                RoleFilter::class,
            ])
            ->defaultSort('id', 'desc')
            ->paginate(),
    ];
}

tabuna avatar Jul 22 '22 21:07 tabuna

As this issue is referenced in a commit I will close it.

astersnake avatar Aug 16 '22 14:08 astersnake