UserNotice.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\admin\model\user;
  3. use crmeb\traits\ModelTrait;
  4. use crmeb\basic\BaseModel;
  5. /**
  6. * 用户通知 model
  7. * Class UserNotice
  8. * @package app\admin\model\user
  9. */
  10. class UserNotice extends BaseModel
  11. {
  12. /**
  13. * 数据表主键
  14. * @var string
  15. */
  16. protected $pk = 'id';
  17. /**
  18. * 模型名称
  19. * @var string
  20. */
  21. protected $name = 'user_notice';
  22. use ModelTrait;
  23. /**
  24. * @param array $where
  25. * @return array
  26. */
  27. public static function getList($where = [])
  28. {
  29. $model = new self;
  30. $model->order('id desc');
  31. if (!empty($where)) {
  32. $data = ($data = $model->page((int)$where['page'], (int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
  33. // foreach ($data as &$item) {
  34. // if ($item["uid"] != '') {
  35. // $uids = explode(",", $item["uid"]);
  36. // array_splice($uids, 0, 1);
  37. // array_splice($uids, count($uids) - 1, 1);
  38. // $item["uid"] = $uids;
  39. // }
  40. // $item['send_time'] = date('Y-m-d H:i:s', $item['send_time']);
  41. // }
  42. $count = count($data); // self::count();
  43. return compact('data', 'count');
  44. }
  45. return self::page($model, function ($item, $key) {
  46. if ($item["uid"] != '') {
  47. $uids = explode(",", $item["uid"]);
  48. array_splice($uids, 0, 1);
  49. array_splice($uids, count($uids) - 1, 1);
  50. $item["uid"] = $uids;
  51. }
  52. });
  53. }
  54. /**
  55. * 获取用户通知
  56. * @param array $where
  57. * @return array
  58. */
  59. public static function getUserList($where = array())
  60. {
  61. $model = new self;
  62. if (isset($where['title']) && $where['title'] != '')
  63. $model = $model->where('title', 'LIKE', "%" . $where['title'] . "%");
  64. $model = $model->where('type', 2);
  65. $model = $model->order('id desc');
  66. return self::page($model, $where);
  67. }
  68. }