1. Go to this page and download the library: Download marksihor/laravel-filtering 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/ */
marksihor / laravel-filtering example snippets
namespace App\Http\Controllers;
use MarksIhor\LaravelFiltering\Filterable;
class Controller
{
use Filterable;
}
$collection = $this->filter(Model::query())->get(); // give user ability to filter model without any constraints
$collection = $this->filter(Model::where('price', 100))->get(); // predefined filter that user cannot override in request parameters
$collection = $this->rawParams(['status' => 'paid'])->filter(Model::query())->get(); // also a way to predefine parameters that user cannot override
$collection = $this->filterable(['status','paid'])->filter(Model::query())->get(); // allows you to define columns that user can filter
public static $filterable = []; // to define columns that you will be able to filter (not filter (otherwise it won't work)
public static $filterablePivot = [
'role_id' => 'sites',
]; // key = key, value = relation name (to filter by pivot table columns, otherwise it won't work)
public static $morphSubRelations = [
'vault' => ['billingAddress']
]; // to filter through morph relation, need to specify morph relation sub relations
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.