| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace app\common\model\movie\film;
- use app\model\BaseModel;
- class Film extends BaseModel
- {
- protected $name = 'movie_film';
- public static function tablePk(): ?string
- {
- return 'id';
- }
- /**
- * @param $model
- * @param array $where
- * @return Film
- */
- public function search($model = null, array $where = [])
- {
- $model = $model ?? new self();
- return $model->when(isset($where['keywords']) && $where['keywords'], function ($query) use ($where) {
- $query->where('title', 'like', "%{$where['keywords']}%");
- })->when(isset($where['cate_one_id']) && $where['cate_one_id'], function ($query) use ($where) {
- $query->where('cate_one_id', $where['cate_one_id']);
- })->when(isset($where['cate_two_id']) && $where['cate_two_id'], function ($query) use ($where) {
- $query->where('cate_two_id', $where['cate_two_id']);
- })->when(isset($where['city']) && $where['city'], function ($query) use ($where) {
- $query->where('city', 'like', "%{$where['city']}%");
- });
- }
- }
|