1. Go to this page and download the library: Download maksa988/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/ */
maksa988 / laravel-filters example snippets
namespace App\Filters;
use Maksa988\LaravelFilters\Filters;
class PostFilter extends Filters
{
/**
* Available filters
*
* @var array
*/
protected $filters = [
'title',
];
/**
* @param string $value
* @return \Illuminate\Database\Eloquent\Builder
*/
public function title($value)
{
return $this->builder->where('title', $value);
}
}
/**
* Display a listing of the resource.
*
* @param Post $post
* @param PostFilter $filter
* @return \Illuminate\View\View
*/
public function index(Post $post, PostFilter $filter)
{
$list = $post->filter($filter)->paginate(20);
return $this->view(compact('list'));
}
class Post extends Model
{
use HasFilters;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.