/** * The attributes that are mass assignable. * * @var array */ protected$fillable = [ 'name', 'email', 'password', ];
/** * The attributes that should be hidden for arrays. * * @var array */ protected$hidden = [ 'password', 'remember_token', ];
/** * Get the identifier that will be stored in the subject claim of the JWT. * * @return mixed */ publicfunctiongetJWTIdentifier() { return$this->getKey(); }
/** * Return a key value array, containing any custom claims to be added to the JWT. * * @return array */ publicfunctiongetJWTCustomClaims() { return []; } }
classAuthControllerextendsController { /** * Create a new AuthController instance. * * @return void */ publicfunction__construct() { $this->middleware('auth:api')->except('login'); }
/** * Get a JWT via given credentials. * * @return \Illuminate\Http\JsonResponse */ publicfunctionlogin(Request $request) { $credentials = $request->only(['email', 'password']);