1. Go to this page and download the library: Download zihad/pilter 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/ */
zihad / pilter example snippets
namespace App\Filters;
use Zihad\Pilter\Filters\Filter;
class PostFilter extends Filter
{
//
}
namespace App\Models;
use Zihad\Pilter\Traits\Filterable;
// Use Filterable trait in model
class Post extends Model
{
use Filterable;
}
$posts = Post::query()
->applyQuery(['title' => 'Post 1', 'sort' => '-title']), PostFilter::class)
->get();
// Filter method
protected function title($title)
{
$this->getQuery()->where('title', $title);
}
// Sort method
protected function sortTitle($order)
{
$this->getQuery()->orderBy('title', $order);
}