PHP code example of oooiik / laravel-query-filter

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

    

oooiik / laravel-query-filter example snippets


User::filter($validated)->get();

$userFilter = User::createFilter(UserFilter::class);

$userFilter->apply($validated)->query();

$userFilter->apply($validated);
$userFilter->apply($validated_2)->query();

$userFilter->resetApply($validated_3)->query();
 


namespace App\Models;

use Oooiik\LaravelQueryFilter\Traits\Model\Filterable;

class User extends Model
{
    use Filterable;


protected $defaultFilter = UserFilter::class;

public function username($username)
{
    $this->builder->where('username', $username);
}
// $validated = ['username' => 'name']