Maginium
Docs
Docs
  • Welcome
  • Getting Started
    • Quickstart
    • Installation
    • Structure
  • The Basics
    • Concurrency
    • 🔤Strings
    • ⚙️Actions
    • 🗃️Cache
    • 🗂️Collections
    • 🔲Component
    • ⚙️Config
    • 💬Console
    • 🗃️Database
      • Overview
      • Eloquent
      • Seeder
      • Migration
      • Models
      • Factories
      • Schemas
      • Traits
      • Concerns
    • 🛅Container
    • 🔠Enum
    • 📦Event
    • 📝Log
    • 🔢Pagination
    • 💬Prompts
    • 🌐Request
    • 📡Response
    • ⚡Redis
    • 📏Resize
    • 🔌Serializer
      • Json
      • Serializer
      • Closure Serializer
    • 🔑Uuid
    • 👤Avatar
    • 🔐Hashing
    • 📤Dto
      • Overview
      • Attributes
    • 🌍Locale
    • 🔗Token
      • Api Keys
      • Admin Token
      • Customer Token
    • 🕘Message Queue
    • 🖼️Media
    • Helpers
    • 📜Crud
      • Filters and Sorts
        • introduction
        • Basic Usage
        • JS Examples
          • Available Methods
          • Sorts
          • Filters
        • Rename Fields
        • Relation Fields
        • Changing Params Source
        • Allowed Fields
        • Queries and javascript examples
        • Sort null values last
        • Restrict
        • Custom Filters
  • Commerce Modules
    • API Key Module
    • Auth Module
    • Cart Module
    • Customer Module
    • Inventory Module
    • Fulfillment Module
    • Order Module
    • Payment Module
    • Pricing Module
    • Product Module
    • Promotion Module
    • User Module
  • SDKs and Tools
    • create-maginium-app
    • Maginium CLI
    • JS SDK
    • Storefront Starter
Powered by GitBook
On this page
  • Filters
  • Sort
  • Sort Basics
  1. The Basics
  2. Crud
  3. Filters and Sorts

Basic Usage

Filters

Add Filterable trait to your model to get filter functionalities.

use Maginium\Framework\Crud\Traits\Filterable;

class Post extends Model
{
    use Filterable;

    //
}

Now add filter() to your model eloquent query in the controller.

use App\Models\Post;

class PostController extends Controller
{
    public function index()
    {
        return Post::filter()->get();
    }
}

Sort

Sort Basics

Add Sortable trait to your model to get sorts functionalities.

use Maginium\Framework\Crud\Traits\Sortable;

class Post extends Model
{
    use Sortable;

    //
}

Now add sort() to your eloquent query in the controller.

use App\Models\Post;

class PostController extends Controller
{
    public function index()
    {
        return Post::sort()->get();
    }
}
PreviousintroductionNextJS Examples

Last updated 3 months ago

By default, it gives access to all filters available. here is the list of . if you want to explicitly specify which filters to use in this call head to restrict filters section.

Now sort can be applied as instructed in .

📜
available filters
apply sort