Information.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\Apply;
  5. use app\common\model\Like;
  6. use app\common\model\SystemMessages;
  7. use app\common\model\User;
  8. /**
  9. * 消息
  10. */
  11. class Information extends Api
  12. {
  13. protected $noNeedRight = ['*'];
  14. protected $noNeedLogin = [''];
  15. /**
  16. * 消息
  17. */
  18. public function index(){
  19. }
  20. /**
  21. * 彼此喜欢
  22. */
  23. public function eachLike(){
  24. $like = Like::with('like')->where(['uid'=>$this->auth->id])->order('id','desc')->select();
  25. foreach ($like as $k=>&$v){
  26. if($v['like']==null){
  27. unset($like[$k]);
  28. }else{
  29. $v['like_user'] = User::where('id',$v['like']['uid'])->field('id,id_authentication,avatar,createtime,nickname,username')->find();
  30. }
  31. }
  32. $this->success('',$like);
  33. }
  34. /**
  35. * 我申请的
  36. */
  37. public function weApply(){
  38. $uid = $this->auth->id;
  39. $data = Apply::all(['uid'=>$uid]);
  40. $this->success('',$data);
  41. }
  42. /**
  43. * 系统通知
  44. */
  45. public function systemMessages(){
  46. $uid = $this->auth->id;
  47. $systemMessages = SystemMessages::all(['uid'=>$uid,'type'=>1,'status'=>1]);
  48. foreach ($systemMessages as $v){
  49. $v->save(['isread'=>1]);
  50. }
  51. $this->success('',$systemMessages);
  52. }
  53. }