Pagination on the pireps/flights on the front-end
This commit is contained in:
45
app/Repositories/Criteria/WhereCriteria.php
Normal file
45
app/Repositories/Criteria/WhereCriteria.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Criteria;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Prettus\Repository\Contracts\CriteriaInterface;
|
||||
use Prettus\Repository\Contracts\RepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class RequestCriteria
|
||||
* @package Prettus\Repository\Criteria
|
||||
*/
|
||||
class WhereCriteria implements CriteriaInterface
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
protected $request, $where;
|
||||
|
||||
public function __construct($request, $where)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->where = $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply criteria in query repository
|
||||
*
|
||||
* @param Builder|Model $model
|
||||
* @param RepositoryInterface $repository
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function apply($model, RepositoryInterface $repository)
|
||||
{
|
||||
if($this->where) {
|
||||
$model = $model->where($this->where);
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user