Role.php 1000 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Role extends Model
  5. {
  6. // use Notifiable;
  7. protected $fillable = ['name','permissions','desc','disable'];
  8. protected $hidden = [];
  9. // Rest omitted for brevity
  10. /**
  11. * Get the identifier that will be stored in the subject claim of the JWT.
  12. *
  13. * @return mixed
  14. */
  15. public function getJWTIdentifier()
  16. {
  17. return $this->getKey(); /*自己可以定义的生成token的参数,我用的是将主键加密*/
  18. }
  19. /**
  20. * Return a key value array, containing any custom claims to be added to the JWT.
  21. *
  22. * @return array
  23. */
  24. public function getJWTCustomClaims()
  25. {
  26. return [];
  27. }
  28. //定义表
  29. protected $table = "roles";
  30. //定义主键
  31. protected $primaryKey = "id";
  32. /**
  33. * 获得拥有此角色的管理员。
  34. */
  35. public function admin()
  36. {
  37. return $this->belongsTo('App\Admin','id','role_id');
  38. }
  39. }