UserNotice.php 2.1 KB

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