12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Repositories\Criteria;
- use App\Models\Role;
- use Illuminate\Http\Request;
- use Prettus\Repository\Contracts\CriteriaInterface;
- use Prettus\Repository\Contracts\RepositoryInterface;
- class ResourceCriteria extends RequestCriteria implements CriteriaInterface
- {
- /**
- * @var \Illuminate\Http\Request
- */
- protected $request;
- public function __construct(Request $request)
- {
- $this->request = $request;
- }
- /**
- * @inheritDoc
- */
- public function apply($model, RepositoryInterface $repository)
- {
- if ($this->request->filled('status')) {
- $model = $model->where('status', $this->request->get('status'));
- }
- $model = $model->orderBy("id", 'desc');
- return parent::apply($model, $repository);
- }
- }
|