Cinema.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\common\model\movie\cinema;
  3. use app\model\BaseModel;
  4. class Cinema extends BaseModel
  5. {
  6. protected $name = 'movie_cinema';
  7. public static function tablePk(): ?string
  8. {
  9. return 'id';
  10. }
  11. /**
  12. * @param $model
  13. * @param array $where
  14. * @return Cinema
  15. */
  16. public function search($model = null, array $where = [])
  17. {
  18. $model = $model ?? new self();
  19. return $model->when(isset($where['cinema_name']) && $where['cinema_name'], function ($query) use ($where) {
  20. $query->where('cinema_name', 'like', "%{$where['cinema_name']}%");
  21. })->when(isset($where['cate_one_id']) && $where['cate_one_id'], function ($query) use ($where) {
  22. $query->where('cate_one_id', $where['cate_one_id']);
  23. })->when(isset($where['cate_two_id']) && $where['cate_two_id'], function ($query) use ($where) {
  24. $query->where('cate_two_id', $where['cate_two_id']);
  25. })->when(isset($where['city']) && $where['city'], function ($query) use ($where) {
  26. $query->where('city', 'like', "%{$where['city']}%");
  27. });
  28. }
  29. }