User.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 Authenticatable;
  7. class User extends Authenticatable implements JWTSubject # 这里别忘了加
  8. {
  9. use Notifiable;
  10. use SoftDeletes;
  11. protected $guarded=[];
  12. // protected $fillable=['nickname','name','phone','cre_num','level','openId','unionId','status','avatar','sex','store_id','card_behind_img','card_front_img','remark','password'];
  13. // Rest omitted for brevity
  14. /**
  15. * Get the identifier that will be stored in the subject claim of the JWT.
  16. *
  17. * @return mixed
  18. */
  19. public function getJWTIdentifier()
  20. {
  21. return $this->getKey();
  22. }
  23. /**
  24. * Return a key value array, containing any custom claims to be added to the JWT.
  25. *
  26. * @return array
  27. */
  28. public function getJWTCustomClaims()
  29. {
  30. return [];
  31. }
  32. protected $table='user';
  33. public function store(){
  34. return $this->hasOne(Store::class,'id','store_id');
  35. }
  36. }