[Vuejs]-How can get authenticated user role from pivot table via Vue JS in Laravel

1👍

Check the following things

1) User.php your model file and make sure it has the roles relation loaded.

protected $with = ['roles']

Print in console user data and see that roles have been loaded.

2) You have a typo on isAdmin() code

isAdmin() {
     //return this.user.slug === 'admin'; 
     return this.user.roles.slug === 'admin';
}

This should work fine.

Leave a comment