Retrieve List of Roles related to User using spatie/laravel-fractal, Permissions works perfectly

171 Views Asked by At

I followed this topic on getting list of roles and permissions through user model using spatie/laravel-permission but none are engaging on my kind of concern. Want to retrieve list of roles related to user using spatie/laravel-fractal through $user->roles and $user->permissions just like zizaco/entrust when I call fractal($user, new UserTransformer)->parseIncludes(['roles', 'permissions'])->toArray();, used $this->collection($user->roles, new RoleTranformer) in UserTranformer.php but throws Symfony\Component\Debug\Exception\FatalThrowableError. I am building an API project using laravel 5.7 and spatie/laravel-permission and spatie/laravel-fractal so trying to organise json response using relations.

0

There are 0 best solutions below