LifeTeacher.php 2.4 KB

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