LifePlay.php 2.4 KB

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