LifeCinema.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace app\admin\model;
  3. use support\Db;
  4. use support\Model;
  5. /**
  6. * 商品模型
  7. * Class Users
  8. * @package app\admin\model
  9. */
  10. class LifeCinema extends Model
  11. {
  12. const ROLE_STATUS = 1;
  13. const IS_DEL_YES = 1;
  14. const IS_DEL_NO = 0;
  15. const GOODS_IS_SHOW = [
  16. self::IS_DEL_YES => '已删除',
  17. self::IS_DEL_NO => '未删除'
  18. ];
  19. /**
  20. * The table associated with the model.
  21. *
  22. * @var string
  23. */
  24. protected $table = 'life_cinema';
  25. public $timestamps = false;
  26. /**
  27. * Notes:获取影片列表
  28. * @param string $keywords
  29. * @param int $page
  30. * @param int $limit
  31. * @return array
  32. * User: ZQ
  33. * Date: 2022/9/13
  34. */
  35. public static function getCinemaList(int $page, int $limit, string $keywords)
  36. {
  37. $list = static::select('*')
  38. ->where(['cinema_is_del'=>static::IS_DEL_NO])
  39. ->when($keywords != '', function ($query) use ($keywords){
  40. $query->where('cinema_name', 'like', '%' . $keywords . '%');
  41. })
  42. ->orderBy('cinema_create_time','DESC')
  43. ->forPage($page, $limit)
  44. ->get();
  45. $count = static::where(['cinema_is_del'=>static::IS_DEL_NO])
  46. ->when($keywords != '', function ($query) use ($keywords){
  47. $query->where('cinema_name', 'like', '%' . $keywords . '%');
  48. })
  49. ->count();
  50. return [$list, $count];
  51. }
  52. /**
  53. * Notes:获取商品列表
  54. * @return array
  55. * User: ZQ
  56. * Date: 2022/9/19`
  57. */
  58. public static function getCinemaAll()
  59. {
  60. $list = static::select(['cinema_id','cinema_name'])
  61. ->where(['cinema_is_del'=>static::IS_DEL_NO])
  62. ->orderBy('goods_create_time','DESC')
  63. ->get();
  64. return $list;
  65. }
  66. /**
  67. * Notes:获取商品名称
  68. * @param string $account
  69. * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
  70. * User: ZQ
  71. * Date: 2022/9/19
  72. */
  73. public static function cinemaMation($admin_cinema)
  74. {
  75. $where = [];
  76. $where['cinema_is_del'] = static::IS_DEL_NO;
  77. $mation = static::where($where)
  78. ->when($admin_cinema != '', function ($query) use ($admin_cinema){
  79. $query->whereIn('cinema_id', $admin_cinema);
  80. })
  81. ->get('cinema_name');
  82. return $mation;
  83. }
  84. }