SysAdminUserModel.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\User\Models;
  3. use Illuminate\Auth\Authenticatable;
  4. use App\Models\BaseModel;
  5. use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
  6. use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
  7. use Laravel\Lumen\Auth\Authorizable;
  8. use Tymon\JWTAuth\Contracts\JWTSubject;
  9. class SysAdminUserModel extends BaseModel implements AuthenticatableContract, AuthorizableContract,JWTSubject
  10. {
  11. use Authenticatable, Authorizable;
  12. protected $table = 'sys_admin_user';
  13. /**
  14. * The attributes that are mass assignable.
  15. *
  16. * @var array
  17. */
  18. protected $fillable = [
  19. 'user_name','real_name','phone','password','salt','last_login_time','status','role_id'
  20. ];
  21. /**
  22. * The attributes excluded from the model's JSON form.
  23. *
  24. * @var array
  25. */
  26. protected $hidden = [
  27. ];
  28. /**
  29. * Get the identifier that will be stored in the subject claim of the JWT.
  30. *
  31. * @return mixed
  32. */
  33. public function getJWTIdentifier()
  34. {
  35. return $this->getKey();
  36. }
  37. /**
  38. * Return a key value array, containing any custom claims to be added to the JWT.
  39. *
  40. * @return array
  41. */
  42. public function getJWTCustomClaims()
  43. {
  44. return [
  45. 'user_name' => $this->user_name,
  46. 'user_id' => $this->id,
  47. ];
  48. }
  49. }