UserInfoModel.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace App\Models;
  3. use App\Models\BaseModel;
  4. use Illuminate\Foundation\Auth\User as Authenticatable;
  5. use Laravel\Passport\HasApiTokens;
  6. use Illuminate\Notifications\Notifiable;
  7. /**
  8. * @description 用户表
  9. * @author system;
  10. * @version 1.0
  11. * @date 2017-05-30 12:16:56
  12. *
  13. */
  14. class UserInfoModel extends Authenticatable
  15. {
  16. use HasApiTokens, Notifiable;
  17. /**
  18. * 数据表名
  19. *
  20. * @var string
  21. *
  22. */
  23. protected $table = 'user_info';
  24. /**
  25. 主键
  26. */
  27. protected $primaryKey = 'id';
  28. //分页
  29. protected $perPage = PAGE_NUMS;
  30. /**
  31. * 可以被集体附值的表的字段
  32. *
  33. * @var string
  34. */
  35. protected $fillable = [
  36. 'tel',
  37. 'password',
  38. 'nickname',
  39. 'sign',
  40. 'pic',
  41. 'money',
  42. 'sex',
  43. 'signture',
  44. 'tall',
  45. 'job',
  46. 'emotion',
  47. 'address',
  48. 'detail_address',
  49. 'status',
  50. 'remember_token',
  51. ];
  52. protected $hidden = ['password'];
  53. public function UserCareUser()
  54. {
  55. return $this->belongsToMany('App\Models\UserInfoModel','user_care_user','user_id','other_user_id');
  56. }
  57. // 系统消息
  58. public function systemInfo()
  59. {
  60. return $this->belongsToMany('App\Models\UserInfoModel','system_info','other_id','user_id')->withPivot('coin');
  61. }
  62. //用户梦想
  63. public function UserDream()
  64. {
  65. return $this->belongsToMany('App\Models\DreamInfoModel','user_dream','user_id','dream_id');
  66. }
  67. //支持的梦想
  68. public function supDream()
  69. {
  70. return $this->belongsToMany('App\Models\DreamInfoModel','system_info','user_id','other_id');
  71. }
  72. //评论的梦想
  73. public function comDream()
  74. {
  75. return $this->belongsToMany('App\Models\DreamInfoModel','comments_info','user_id','dream_id')->withPivot('content', 'level','created_at');
  76. }
  77. //关注的用户
  78. public function myCareNum()
  79. {
  80. return $this->hasMany('App\Models\UserCareUser','user_id','id');
  81. }
  82. //关注我的用户
  83. public function myFens()
  84. {
  85. return $this->hasMany('App\Models\UserCareUser','other_user_id','id');
  86. }
  87. // 我的收藏
  88. public function myCollection()
  89. {
  90. return $this->hasMany('App\Models\UserCareDream','user_id','id');
  91. }
  92. // 回复的梦想
  93. public function replyDream()
  94. {
  95. return $this->belongsToMany('App\Models\CommentInfoModel','reply_comments_info','user_id','comment_id')->withPivot('content', 'level','created_at');
  96. }
  97. }