Worker.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Auth\Authenticatable;
  4. use Laravel\Lumen\Auth\Authorizable;
  5. use Illuminate\Database\Eloquent\Model;
  6. use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
  7. use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
  8. use Tymon\JWTAuth\Contracts\JWTSubject;
  9. class Worker extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
  10. {
  11. use Authenticatable, Authorizable;
  12. /**
  13. * The attributes that are mass assignable.
  14. *
  15. * @var array
  16. */
  17. protected $fillable = [
  18. 'name', 'id'
  19. ];
  20. /**
  21. * The attributes excluded from the model's JSON form.
  22. *
  23. * @var array
  24. */
  25. protected $hidden = [
  26. 'password',
  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 ['role' => 'worker'];
  45. }
  46. //账号状态
  47. const STATUS_OK = 1;
  48. const STATUS_PAUSE = 0;
  49. public static $statusMaps = [
  50. self::STATUS_PAUSE => '暂停使用',
  51. self::STATUS_OK => '正常'
  52. ];
  53. }