1. Go to this page and download the library: Download cerbero/query-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/ */
cerbero / query-filters example snippets
class ActorFilters extends QueryFilters
{
protected function getRules()
{
return [
'acting' => 'bool',
'acted-in' => 'int|digits:4',
];
}
}
php
use Cerbero\QueryFilters\QueryFilters;
/**
* Filter records based on query parameters.
*
*/
class ActorFilters extends QueryFilters
{
/**
* Filter records based on the query parameter "won_oscar"
*
* @return void
*/
public function wonOscar()
{
// $this->query
}
/**
* Filter records based on the query parameter "acting"
*
* @param mixed $bool
* @return void
*/
public function acting($bool)
{
// $this->query
}
/**
* Filter records based on the query parameter "acted-in"
*
* @param mixed $year
* @return void
*/
public function actedIn($year)
{
// $this->query
}
}
php
public function wonOscar()
{
$this->query->where('oscars', '>', 0);
}
public function acting($bool)
{
$this->query->where('acting', $bool);
}
public function actedIn($year)
{
$this->query->whereHas('movies', function ($movies) use ($year) {
$movies->whereYear('release_date', '=', $year);
});
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.