UserNotice.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. $model = new self;
  33. $model->order('id desc');
  34. if(!empty($where)){
  35. $data=($data=$model->page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
  36. foreach ($data as &$item){
  37. if($item["uid"] != ''){
  38. $uids = explode(",",$item["uid"]);
  39. array_splice($uids,0,1);
  40. array_splice($uids,count($uids)-1,1);
  41. $item["uid"] = $uids;
  42. }
  43. $item['send_time']=date('Y-m-d H:i:s',$item['send_time']);
  44. }
  45. $count=self::count();
  46. return compact('data','count');
  47. }
  48. return self::page($model,function($item,$key){
  49. if($item["uid"] != ''){
  50. $uids = explode(",",$item["uid"]);
  51. array_splice($uids,0,1);
  52. array_splice($uids,count($uids)-1,1);
  53. $item["uid"] = $uids;
  54. }
  55. });
  56. }
  57. /**
  58. * 获取用户通知
  59. * @param array $where
  60. * @return array
  61. */
  62. public static function getUserList($where = array()){
  63. $model = new self;
  64. if(isset($where['title']) && $where['title'] != '') $model = $model->where('title','LIKE',"%".$where['title']."%");
  65. $model = $model->where('type',2);
  66. // $model = $model->where('is_send',0);
  67. $model = $model->order('id desc');
  68. return self::page($model,$where);
  69. }
  70. }