PHP code example of otisz / laravel-eloquent-filter

1. Go to this page and download the library: Download otisz/laravel-eloquent-filter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

otisz / laravel-eloquent-filter example snippets




namespace App\Filters;

use Illuminate\Http\Request;
use Otisz\EloquentFilter\Filter;

/**
 * @property \Illuminate\Database\Eloquent\Builder $builder
 * @method static \App\Filters\TestFilter boot($class)
 * @mixin \Illuminate\Database\Eloquent\Builder
 */
final class TestFilter extends Filter
{
        /**
         * @param  \Illuminate\Http\Request|null  $request
         *
         * @return self
         */
        public function search(Request $request = null)
        {
            //
    
            return $this;
        }
    
        /**
         * @param  \Illuminate\Http\Request|null  $request
         *
         * @return self
         */
        public function order(Request $request = null)
        {
            //
    
            return $this;
        }
}


// Eloquent Builder:
TestFilter::boot(Model::query());
TestFilter::boot(Model::where('column', '=', 1));

// Namespace
TestFilter::boot(Model::class);

// Model
TestFilter::boot(new Model);

TestFilter::boot(Model::class)->search()->order();