PHP code example of gsferro / filtereasy

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

    

gsferro / filtereasy example snippets


    Use FilterEasy;
    

       permission_id[]
       

    /*
    |---------------------------------------------------
    | FilterEasy
    |---------------------------------------------------
    */
    private array $likeFilterFields = [
        // coloque os campos para like
    ];
    
    private array $boolFilterFields = [
        // coloque os campos bool
    ];
    

           posts:title
           relationName = posts
           relationField = title
           

       private array  $likeFilterFields = [
           // demais campos
           "posts:title",
     ];
       

       /*
       |---------------------------------------------------
       | FilterEasy
       |---------------------------------------------------
       */
       private array $otherFilterFields = [
       // coloque outros campos que não esteja no fillable
       ];
      

      /*
      |---------------------------------------------------
      | FilterEasy
      |---------------------------------------------------
      */
      private array $combinedFilterFields = [
       'client' => [
          'name' => 'like',
          'id' => '=',
          'age' => '>',
        ]
      ];
      

       /*
       |---------------------------------------------------
       | FilterEasy
       |---------------------------------------------------
       */
       private array $nullableFilterFields = [
       // coloque os campos que serão verificados se estão null
       ];
      

    
    
    namespace App\Criteria;
    
    use Prettus\Repository\Contracts\CriteriaInterface;
    use Prettus\Repository\Contracts\RepositoryInterface;
    
    class FilterEasyCriteria implements CriteriaInterface
    {
        /**
         * Apply criteria in query repository
         *
         * @param  string  $model
         * @return mixed
         */
        public function apply($model, RepositoryInterface $repository)
        {
            return $model->filterEasyRequest();
        }
    }
    

    public function index(): View
    {
        // set filtereasy
        $this->repository->pushCriteria(new FilterEasyCriteria);

        return view('index', [
            'model' => $this->repository,
        ]);
    }