Worker.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Auth\Authenticatable;
  4. use Laravel\Lumen\Auth\Authorizable;
  5. use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
  6. use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
  7. use Tymon\JWTAuth\Contracts\JWTSubject;
  8. class Worker extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
  9. {
  10. use Authenticatable, Authorizable;
  11. /**
  12. * The attributes that are mass assignable.
  13. *
  14. * @var array
  15. */
  16. protected $fillable = [
  17. 'name', 'id'
  18. ];
  19. /**
  20. * The attributes excluded from the model's JSON form.
  21. *
  22. * @var array
  23. */
  24. protected $hidden = [
  25. 'password',
  26. ];
  27. /**
  28. * Get the identifier that will be stored in the subject claim of the JWT.
  29. *
  30. * @return mixed
  31. */
  32. public function getJWTIdentifier()
  33. {
  34. return $this->getKey();
  35. }
  36. /**
  37. * Return a key value array, containing any custom claims to be added to the JWT.
  38. *
  39. * @return array
  40. */
  41. public function getJWTCustomClaims()
  42. {
  43. return ['role' => 'worker'];
  44. }
  45. //账号状态
  46. const STATUS_OK = 1;
  47. const STATUS_PAUSE = 0;
  48. public static $statusMaps = [
  49. self::STATUS_PAUSE => '暂停使用',
  50. self::STATUS_OK => '正常'
  51. ];
  52. }