Laravel PurityLaravel Purity
Introduction
  • Installation
  • Basic Usage
  • Additional Tutorials
  • Available Filters
  • Filtering
  • Sorting
  • Rename Fields
  • Relation Fields
  • Params Source
  • Allowed Fields
  • Livewire
  • Silent Exceptions
  • Filter

    • Restrict
    • Custom Filters
  • Sort

    • Null Sort
  • Upgrade Guide
Client Package
Ask a Question
GitHub
Introduction
  • Installation
  • Basic Usage
  • Additional Tutorials
  • Available Filters
  • Filtering
  • Sorting
  • Rename Fields
  • Relation Fields
  • Params Source
  • Allowed Fields
  • Livewire
  • Silent Exceptions
  • Filter

    • Restrict
    • Custom Filters
  • Sort

    • Null Sort
  • Upgrade Guide
Client Package
Ask a Question
GitHub
  • Params Source

    • Changing Params Source

Changing Params Source

By Default, Purity gets params from filters index in query params, overwrite this by passing params directly to filter or sort functions:

Filter

// this will get filters from find query params
// `GET /api/users?find[name][$eq]=John`
Post::filter(request()->query('find'))->get();
Post::filter($params)->get();

Post::filter([
            'title' => ['$eq' => 'good post']
        ])->get();
        
Post::filter([
            '$or' => [
                'title' => [
                    '$eq' => 'good post'
                ],
                'author' => [
                    'name' => [ '$eq' => 'John Doe' ],
                    'age' => [ '$gt' => 20 ],
                ],
            ],
        ])->get();

Sort

Post::sort([
            'title',
            'id:desc'
        ])->get();
Edit this page
Last Updated:
Contributors: Abbas mkhzomi
Prev
Rename Fields
Next
Allowed Fields