| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace App\Repositories\Criterias;
- use KZ2\Repositories\Contracts\RepositoryInterface;
- use KZ2\Repositories\Criteria\Criteria;
- class OriginalClassCriteria extends Criteria
- {
- private $params = [];
- public function __construct($params = [])
- {
- $this->params = $params;
- }
- public function apply($model, RepositoryInterface $repository)
- {
- if (!empty($this->params['status'])) {
- $model = $model->where('status', $this->params['status']);
- }
- if (!empty($this->params['name'])) {
- $model = $model->where('name', $this->params['name']);
- }
- if (!empty($this->params['type'])) {
- $model = $model->where('type', $this->params['type']);
- }
- return $model;
- }
- }
|