UserInfoModel.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. public function UserCareUser()
  53. {
  54. return $this->belongsToMany('App\Models\UserInfoModel','user_care_user','user_id','other_user_id');
  55. }
  56. // 系统消息
  57. public function systemInfo()
  58. {
  59. return $this->belongsToMany('App\Models\UserInfoModel','system_info','other_id','user_id')->withPivot('coin');
  60. }
  61. public function UserDream()
  62. {
  63. return $this->belongsToMany('App\Models\DreamInfoModel','user_dream','user_id','dream_id');
  64. }
  65. public function supDream()
  66. {
  67. return $this->belongsToMany('App\Models\DreamInfoModel','system_info','user_id','other_id');
  68. }
  69. public function myCareNum()
  70. {
  71. return $this->hasMany('App\Models\UserCareUser','user_id','id');
  72. }
  73. public function myFens()
  74. {
  75. return $this->hasMany('App\Models\UserCareUser','other_user_id','id');
  76. }
  77. public function myCollection()
  78. {
  79. return $this->hasMany('App\Models\UserCareDream','user_id','id');
  80. }
  81. }