PHP code example of myerscode / laravel-query-strategies
1. Go to this page and download the library: Download myerscode/laravel-query-strategies 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/ */
myerscode / laravel-query-strategies example snippets
new Filter(Item::query(), new MyStrategy, $request->query->all());
class Foo extends Model
{
use IsFilterableTrait;
public $strategy = BarStrategy::class;
}
$filter = (new Foo)->filter();
$filter->apply(); // Applies filter, order, limit, with methods and returns the paginated query
$filter->filter(); // Only applies filters and returns the Filter class
$filter->order(); // Only applies ordering and returns the Filter class
$filter->limit(); // Only applies limiting and returns the Filter class
$filter->with(); // Only applies
// basic implamentation, that will just enable all default clauses for the strategy and will not mask the column name
$config = [
'foo',
'bar'
];