Notice.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 Notice extends Model
  11. {
  12. const STATUS_DEL_NO = '0';
  13. const STATUS_DEL_YES = '1';
  14. const STATUS_DEL = [
  15. self::STATUS_DEL_NO => '正常',
  16. self::STATUS_DEL_YES => '删除'
  17. ];
  18. /**
  19. * The table associated with the model.
  20. *
  21. * @var string
  22. */
  23. protected $table = 'medical_care_notice';
  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/9/14
  33. */
  34. public static function getNoticeList(int $page, int $limit, string $keywords)
  35. {
  36. $list = static::select('*')->where(['notice_del'=>static::STATUS_DEL_NO])
  37. ->when($keywords != '', function ($query) use ($keywords){
  38. $query->where('notice_name', 'like', '%' . $keywords . '%');
  39. })
  40. ->forPage($page,$limit)
  41. ->orderBy('notice_sort','DESC')
  42. ->orderBy('notice_create_time','DESC')
  43. ->get();
  44. $count = static::where(['notice_del'=>static::STATUS_DEL_NO])
  45. ->when($keywords != '', function ($query) use ($keywords){
  46. $query->where('notice_name', 'like', '%' . $keywords . '%');
  47. })
  48. ->count();
  49. return [$list,$count];
  50. }
  51. /**
  52. * Notes:查询指定条件下的某个字段内容
  53. * @param int $notice_id
  54. * @param string $field
  55. * User: ZQ
  56. * Date: 2022/9/27
  57. */
  58. public static function getValue(int $notice_id, string $field)
  59. {
  60. return static::where(['notice_id' => $notice_id])->value($field);
  61. }
  62. }