Admin.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 Authuser;
  7. class Admin extends Authuser implements JWTSubject
  8. {
  9. use Notifiable;
  10. use SoftDeletes;
  11. protected $fillable = ['name','password','role_id','status','mobile'];
  12. protected $hidden = ['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(); /*自己可以定义的生成token的参数,我用的是将主键加密*/
  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. // public $timestamps = false;
  33. //定义表
  34. protected $table = "admins";
  35. //定义主键
  36. protected $primaryKey = "id";
  37. //获取管理员角色信息
  38. public function role()
  39. {
  40. //<<<<<<< HEAD
  41. return $this->hasOne('App\Models\Role','id','role_id');
  42. }
  43. //=======
  44. // return $this->hasOne('App\Role','id','role_id');
  45. // }
  46. //
  47. //
  48. //
  49. //>>>>>>> 9aa477479386789a8615d89285e74706ec72fbab
  50. }