Skip to content

Instantly share code, notes, and snippets.

@muhtarudinsiregar
Created October 28, 2018 14:50
Show Gist options
  • Save muhtarudinsiregar/62a740cfe93ccadc8b68d0120f9a4e84 to your computer and use it in GitHub Desktop.
Save muhtarudinsiregar/62a740cfe93ccadc8b68d0120f9a4e84 to your computer and use it in GitHub Desktop.
Implement JWTSubject in user model
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Tymon\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable implements JWTSubject
{
use Notifiable;
/**
* 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
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment