PHP code example of stobys / laravel-filterable

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

    

stobys / laravel-filterable example snippets


\App\User::filter()->get()

use Filterable;

protected $filterable_fields = [
	'id'			=> 'is',
	'username'		=> 'like',
	'created_at'	=> 'between',
	'created_after'	=> 'scope'
];


class User extends Model
{
    use Filterable;

    protected $filterable_fields = [
        'id'    => 'is',
        'username'    => 'like',
        'created_at'  => 'between',
        'created_after' => 'scope'
    ];

    public function scopeCreatedAfter($query, $time)
    {
        return $query->where('created_at', '>', $time);
    }
}