| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- /**
- * 通用With.
- *
- * @author nj
- * @date 2021-01-30 09:52:38
- */
- namespace App\Repositories\Criterias;
- use Illuminate\Database\Eloquent\Builder;
- use KZ2\Laravel\Repositories\Contracts\RepositoryInterface;
- use KZ2\Laravel\Repositories\Criteria\Criteria;
- class CommonWithCriteria extends Criteria
- {
- private $withParams = [];
- public function __construct($withParams)
- {
- $this->withParams = $withParams;
- }
- /**
- * @param Builder $model
- * @param RepositoryInterface $repository
- * @return mixed|void
- */
- public function apply(
- $model,
- RepositoryInterface $repository
- ) {
- $model = $model->with($this->withParams);
- return $model;
- }
- }
|