PHP code example of pianzhou / laravel-query-filter
1. Go to this page and download the library: Download pianzhou/laravel-query-filter 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/ */
pianzhou / laravel-query-filter example snippets
// demo one
DemoModel::filter($request->get('name'), function(int $value) {
$this->where('name', 'like', $value);
}, \Pianzhou\Laravel\Query\Filter\Filter::MODE_NULL);
// demo two
DemoModel::filters($request->only('column1', 'column2', 'column3'))->get();
// demo three
DemoModel::filters($request->only('name'), function (\Pianzhou\Laravel\Query\Filter\Filter $filter) {
$filter->where('name', 'like')
->where('nickname', 'like');
})->get();
// demo four
DemoModel::filters($request->only('name'), function (\Pianzhou\Laravel\Query\Filter\Filter $filter) {
$filter->when('name', function (int $value) {
$this->where('name', 'like', $value);
})
->when('nickname', function (string $value) {
$this->where('nickname', 'like', $value);
}, \Pianzhou\Laravel\Query\Filter\Filter::MODE_NULL);
})->get();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.