vendredi 28 avril 2017

Laravel 5 JWTAuth to check the user role is admin or not

when front-end parse a token to back-end, how to use JwtAuth to check the user relationship(role) that is a admin (role=1) or normal (role=0) ?

any idea?

The relationship with user and role

User

public function role()
{
   return $this->hasOne('FACI\Entity\User\Role','user_id','id');
}

Role

protected $fillable = ['user_id','role'];

public function user()
{
    return $this->belongsTo('FACI\Entity\User','user_id','id');
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire