| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- /**
- * 通用With.
- *
- * @author jim <jim458734573@gmail.com>
- * @date 2020-01-30 09:52:38
- */
- declare(strict_types=1);
- namespace App\Repositories\Criterias;
- use Hyperf\Database\Query\Builder;
- use KZ2\Repositories\Contracts\RepositoryInterface;
- use KZ2\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;
- }
- }
|