123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- namespace App\Models;
- use Illuminate\Foundation\Auth\User as Authenticatable;
- use Laravel\Passport\HasApiTokens;
- use Illuminate\Notifications\Notifiable;
- /**
- * @description 用户表
- * @author system;
- * @version 1.0
- * @date 2017-05-30 12:16:56
- *
- */
- class UserInfoModel extends Authenticatable
- {
- use HasApiTokens, Notifiable;
- /**
- * 数据表名
- *
- * @var string
- *
- */
- protected $table = 'user_info';
- /**
- 主键
- */
- protected $primaryKey = 'id';
- //分页
- protected $perPage = PAGE_NUMS;
- /**
- * 可以被集体附值的表的字段
- *
- * @var string
- */
- protected $fillable = [
- 'phone',
- 'password',
- 'nickname',
- 'sign',
- 'avatar',
- 'money',
- 'coin',
- 'sex',
- 'city',
- 'signture',
- 'height',
- 'work',
- 'emotion',
- 'address',
- 'detail_address',
- 'status',
- 'remember_token',
- 'birthday',
- 'wechat',
- 'add_fens_number',
- 'jpush',
- 'step',
- ];
- protected $hidden = ['password'];
- public function UserCareUser()
- {
- return $this->belongsToMany('App\Models\UserInfoModel','user_care_user','user_id','other_user_id');
- }
- public function UserCareMe()
- {
- return $this->belongsToMany('App\Models\UserInfoModel','user_care_user','other_user_id','user_id');
- }
- public function UserCareDream()
- {
- return $this->belongsToMany('App\Models\DreamInfoModel','user_care_dream','user_id','dream_id')->with(['user'])->withPivot('interaction_number','dream_user_id')->orderBy('updated_at');
- }
- // 系统消息
- public function systemInfo()
- {
- return $this->hasMany('App\Models\SystemInfoModel','user_id','id');
- }
- //用户梦想
- public function dreams()
- {
- return $this->hasMany('App\Models\DreamInfoModel','user_id','id');
- }
- //支持的梦想
- public function supDream()
- {
- return $this->belongsToMany('App\Models\DreamInfoModel','support_dream','user_id','dream_id');
- }
- //评论的梦想
- public function comDream()
- {
- return $this->belongsToMany('App\Models\DreamInfoModel','comments_info','user_id','dream_id')->withPivot('content', 'level','created_at');
- }
- //收藏的梦想
- public function careDreams()
- {
- return $this->belongsToMany('App\Models\DreamInfoModel','user_care_dream','user_id','dream_id');
- }
- //关注我的用户
- public function fens()
- {
- return $this->hasMany('App\Models\UserCareUser','other_user_id','id');
- }
- // 我的收藏
- public function collection()
- {
- return $this->belongsToMany('App\Models\DreamInfoModel','user_care_dream','user_id','dream_id')->withPivot('interaction_number','dream_user_id');
- }
- // 回复的梦想
- public function replyDream()
- {
- return $this->belongsToMany('App\Models\CommentInfoModel','reply_comments_info','user_id','comment_id')->withPivot('content', 'level','created_at');
- }
- // 搜索
- public function search()
- {
- return $this->hasMany('App\Models\SearchInfoModel','user_id','id');
- }
- // 获取所有梦想的图片
- public function allImgs()
- {
- return $this->hasManyThrough('App\Models\DreamImages', 'App\Models\DreamInfoModel','user_id','dream_id');
- }
- // 获取所有梦想的互动
- public function allInteraction()
- {
- return $this->hasManyThrough('App\Models\InteractionInfo', 'App\Models\DreamInfoModel','user_id','dream_id');
- }
- // 我的银行卡
- public function bank()
- {
- return $this->hasMany('App\Models\UserBank','user_id','id');
- }
- }
|