User.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Models;
  3. use Tymon\JWTAuth\Contracts\JWTSubject;
  4. use Illuminate\Notifications\Notifiable;
  5. use Illuminate\Database\Eloquent\SoftDeletes;
  6. use Illuminate\Foundation\Auth\User as Authuser;
  7. class User extends Authuser implements JWTSubject
  8. {
  9. use Notifiable;
  10. // use SoftDeletes;
  11. // protected $fillable = ['nickname','realname','phone','hard_num','simple_num','old_num','promise_num','status','created_at','','',''];
  12. //
  13. // protected $hidden = ['password'];
  14. // Rest omitted for brevity
  15. /**
  16. * Get the identifier that will be stored in the subject claim of the JWT.
  17. *
  18. * @return mixed
  19. */
  20. public function getJWTIdentifier()
  21. {
  22. return $this->getKey(); /*自己可以定义的生成token的参数,我用的是将主键加密*/
  23. }
  24. /**
  25. * Return a key value array, containing any custom claims to be added to the JWT.
  26. *
  27. * @return array
  28. */
  29. public function getJWTCustomClaims()
  30. {
  31. return [];
  32. }
  33. // public $timestamps = false;
  34. //定义表
  35. protected $table = "user";
  36. //定义主键
  37. protected $primaryKey = "id";
  38. public function get_address(){
  39. return $this->hasOne(Address::class,'user_id');
  40. }
  41. public function get_dwbs_user(){
  42. return $this->hasManyThrough(DwbsUser::class,User::class,'dwbs_id','id','user_id','id');
  43. }
  44. public function enroll(){
  45. return $this->hasOne(Enroll::class,'user_id','id');
  46. }
  47. }