LifeBookScheduling.php 2.7 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 LifeBookScheduling extends Model
  11. {
  12. const IS_DEL_YES = 1;
  13. const IS_DEL_NO = 0;
  14. const SCHEDULING_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_book_scheduling';
  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/14
  33. */
  34. public static function getBookSchedulingList(int $page, int $limit, string $keywords)
  35. {
  36. $list = static::select(['life_book_scheduling.*','life_book.life_book_name','category.category_name'])
  37. ->where(['scheduling_is_del'=>static::IS_DEL_NO])
  38. ->when($keywords != '', function ($query) use ($keywords){
  39. $query->where('scheduling_book_id', 'like', '%' . $keywords . '%');
  40. })
  41. ->leftJoin('life_book','life_book_id','=','life_book_scheduling.scheduling_book_id')
  42. ->leftJoin('category','category_id','=','life_book_scheduling.scheduling_category_id')
  43. ->orderBy('scheduling_create_time','DESC')
  44. ->forPage($page, $limit)
  45. ->get();
  46. $count = static::where(['scheduling_is_del'=>static::IS_DEL_NO])
  47. ->when($keywords != '', function ($query) use ($keywords){
  48. $query->where('scheduling_name', 'like', '%' . $keywords . '%');
  49. })
  50. ->count();
  51. return [$list, $count];
  52. }
  53. /**
  54. * Notes:获取所有课程
  55. * @return array
  56. * User: ZQ
  57. * Date: 2022/10/14
  58. */
  59. public static function getBookAll()
  60. {
  61. $list = static::select(['scheduling_id','scheduling_name'])
  62. ->where(['scheduling_is_del'=>static::IS_DEL_NO])
  63. ->orderBy('scheduling_create_time','DESC')
  64. ->get();
  65. return $list;
  66. }
  67. /**
  68. * Notes:获取课程目录名称
  69. * @param string $account
  70. * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
  71. * User: ZQ
  72. * Date: 2022/10/14
  73. */
  74. public static function schedulingMation($admin_cinema)
  75. {
  76. $where = [];
  77. $where['scheduling_is_del'] = static::IS_DEL_NO;
  78. $mation = static::where($where)
  79. ->when($admin_cinema != '', function ($query) use ($admin_cinema){
  80. $query->whereIn('scheduling_id', $admin_cinema);
  81. })
  82. ->get('scheduling_name');
  83. return $mation;
  84. }
  85. }