PHP code example of kouks / laravel-filters

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

    

kouks / laravel-filters example snippets


namespace App\Filters;

use Koch\Filters\Filter;

class PostFilter extends Filter
{
    //
}

namespace App\Filters;

use Koch\Filters\Filter;

class PostFilter extends Filter
{
    protected $searchable = ['id', 'title', 'body'];
    
    protected $orderable = [
        'id' => 'id',
        'title' => 'title',
    ];
}

namespace App\Filters;

use Koch\Filters\Filter;

class PostFilter extends Filter
{
    protected $searchable = ['id', 'title', 'body'];
}

namespace App\Filters;

use Koch\Filters\Filter;

class PostFilter extends Filter
{
    protected $orderable = [
        'id' => 'id',
        'topic' => 'title',
    ];
}

namespace App\Filters;

use Koch\Filters\Filter;

class PostFilter extends Filter
{
    protected $searchable = ['id', 'title', 'authors.id', 'authors.name'];
}

namespace App\Filters;

use Koch\Filters\Filter;

class PostFilter extends Filter
{
    protected $orderable = [
        'id' => 'id', 
        'title' => 'title', 
        'author_id' => 'authors.id', 
        'author_name' => 'authors.name',
    ];
}

namespace App\Filters;

use Koch\Filters\Filter;

class PostFilter extends Filter
{
    public function popular($direction)
    {
        return $this->builder->orderBy('votes', $direction);
    }
}