PHP code example of krenor / eloquent-filter

1. Go to this page and download the library: Download krenor/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/ */

    

krenor / eloquent-filter example snippets


namespace App\Http\Models;

use Illuminate\Database\Eloquent\Model;
use Krenor\EloquentFilter\FilterableTrait;

class Order extends Model
{
	use FilterableTrait;

    ...
}

    protected $filterable = [
        // column name => column alias
        'status_id' => ['status' => [
            // value aliases in database => input value
            1 => 'pending',
            2 => 'processing',
            3 => 'completed'
        ]
    ]