FilterableFilterable
Home
📦 Installation
  • Setting Up Filterable
  • Discover Command
  • Listing All Filters
  • Testing Filters
  • Inspecting Filterable Classes
  • Caching
GitHub
Home
📦 Installation
  • Setting Up Filterable
  • Discover Command
  • Listing All Filters
  • Testing Filters
  • Inspecting Filterable Classes
  • Caching
GitHub
  • Home
  • Introduction
  • Installation
  • Service Provider
  • How It Works
  • Engines

    • Invokable
    • Tree
    • Ruleset
    • Expression
  • Features

    • Lifecycle Hooks
    • Header-Driven Filter Mode
    • Auto Register Filterable Macro
    • Conditional Logic
    • Filter Aliases
    • Through callbacks
    • Auto Binding
    • Custom engines
    • Data Provisioning
  • Execution

    • Invoker
  • API Reference

    • Filterable
    • Filterable facade
    • Payload
    • Sorter
  • Caching

    • Overview
    • Getting Started
    • Strategies
    • Auto Invalidation
    • Cache Profiles
    • Scoping Cache
    • Monitoring Cached Items
    • API Reference
    • Examples
  • CLI

    • Setup Filterable
    • Discover Filters
    • Test Filter
    • List Filters
    • Inspect Filter
  • Exceptions
  • Event System
  • Profile Management
  • Profiler
  • Sorting
  • Authorization
  • Validation
  • Sanitization

📦 Installation

To install Filterable, simply use Composer to add it to your project:

composer require kettasoft/filterable

Service Provider Registration

Add the following line to the providers array in config/app.php:

'providers' => [

    ...

    Kettasoft\Filterable\Providers\FilterableServiceProvider::class,

];

Publishing Configuration and Stubs

After installation, you can publish the configuration file and stubs with the following commands:

php artisan vendor:publish --provider="Kettasoft\Filterable\Providers\FilterableServiceProvider" --tag="config"
php artisan vendor:publish --provider="Kettasoft\Filterable\Providers\FilterableServiceProvider" --tag="stubs"

Step 1: Add the Filterable Trait to Your Model

To enable filtering on your model, you need to include the Filterable trait in the model you want to apply filters on.

<?php

use Kettasoft\Filterable\Filterable;

class Post extends Model
{
    use Filterable;
}

Step 2: Create a Custom Filter Class

You can generate a custom filter class for your model by running the artisan command:

php artisan kettasoft:make-filter PostFilter --filters=title,status

This command will generate a filter class where you can define custom filter methods.


Edit this page
Last Updated:
Contributors: Abdalrhman Emad Saad, kettasoft
Prev
Introduction
Next
Service Provider