PHP code example of hugorut / filterable

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

    

hugorut / filterable example snippets


#Set the package to run all constraints against an Article model
$filter = Filter::setType('articles');

#filter those articles by the Page and Author model so that only
#articles that appear with these contraints are returned
$filter->only([
    'pages' => [1, 2], 
    'authors' => [4, 7, 9]
])->get();

'providers' => [
    Hugorut\Filter\Laravel\FilterServiceProvider::class,
];

'aliases' => [
    'Filter'    => Hugorut\Filter\Laravel\Filter::class,
];

'Builders' => [
    'articles' => 'App\Article'
],

'Filters' => [
    'pages' => 'App\Page',
    'authors' => 'App\Author'
],

$filter = Filter::setType('articles');

$filter->only(['pages' => [1, 2]]);
/*-----
* or
-----*/
$filter->without(['pages' => [1, 2]]);

$filter->get();
shell
php artisan vendor:publish
shell
Copied File [/vendor/Filter/src/Hugorut/Filter/config.php] To [/config/filter.php]
Publishing complete for tag []!