Questions tagged [laravel-permission]

Laravel permission is a 3rd party Laravel package developed by Spatie to manage user permissions and roles in a database.

Laravel permission is a 3rd party Laravel package to manage user permissions and roles in a database.

It is maintained by Spatie, a Belgian company that creates websites and web application. This is one of many Laravel packages they maintain.

It can be installed using composer via the following command:

composer require spatie/laravel-permission

Links:

261 questions
4
votes
4 answers

Laravel 5.7 + Spatie Permissions + JWT auth

I'm setting up a REST API using Laravel 5.7. To validate authentication I JWT-auth and for permissions and roles I use Spatie. My problem: when trying to link a role to a user I get the following error Spatie \ Permission \ Exceptions \…
André Luiz
  • 6,642
  • 9
  • 55
  • 105
3
votes
1 answer

How can I add OR relationship in laravel middleware for a Route

I'm using spatie/laravel-permission to add permissions for my routes. One of the routes I have can be accessed by two permissions (earnings, financial_fund). The user doesn't need to have both permissions to access the controller. He can access the…
Abozanona
  • 2,261
  • 1
  • 24
  • 60
3
votes
3 answers

I want to show roles related to users in selection option using laravel

I am trying to show roles which is related to user but unfortunately userRoles are not showing related to user in selection option, please help me how can I match that thanks. Note :- I am using spaite laravel permission docs controller public…
zubair malik
  • 223
  • 1
  • 12
3
votes
1 answer

Illegal offset type when assigning Permission into Role in spatie/laravel-permission using UUID

I have implemented laravel-permission to custom my Model using UUID primary key. Then I created a seeder: $viewemployee = Permission::create(['id' => Str::uuid(), 'name' => 'view employee']); $A = Role::create(['id' => Str::uuid(), 'name' =>…
3
votes
2 answers

Laravel Spatie Permissions - user and role relation get only id and name

I'm using Laravel Spatie Permissions to manage roles and permissions in my app. I'm traing to retrieve only Role id and name in the relation between users and roles. My UserResource looks like this: class UserResource extends JsonResource { /** …
Guido Caffa
  • 1,201
  • 1
  • 12
  • 22
3
votes
2 answers

How to make multiple roles in Spatie Laravel package?

Is possible with Spatie's laravel-permission package to achieve something like what Facebook have with their permissions for pages? Case study, On Facebook you can create a page, then automatically you'll become Admin (assuming it's a role) of that…
ThaCoder
  • 76
  • 1
  • 7
3
votes
1 answer

Customizing Spatie Laravel-Permission Exception Message

I have added the Saptie Laravel Permission Package in a Laravel 5.8 API application. Every works fine and I get exception when a non admin user tries to access admin specific routes. However the default exception is rendered as HTML 403 User does…
Mena
  • 1,873
  • 6
  • 37
  • 77
3
votes
1 answer

How to list all roles with Permissions,in spatie permission Package?

I'm using spatie package for roles and permissions in my laravel project, I need to list all roles with their permissions in a table, is there is any way? [ { id:1, name:"role1", "permissions":[ { …
3
votes
3 answers

How can I correctly implement UUIDs in Laravel with spatie/laravel-permission and webpatser/laravel-uuid?

I have a Laravel 5.7 application using spatie/laravel-permission and normal IDs for models. I want to transition to using UUIDs and I've taken the steps mentioned in webpatser/laravel-uuid Readme file. Everything works with my own models, e.g. with…
3
votes
6 answers

How to remove all roles from the user in spatie/laravel-permission

whats the best or the usual way to remove all roles from a user? I tried $roles = $user->getRoleNames(); $user->removeRole($roles); Return value of App\User::getStoredRole() must implement interface Spatie\Permission\Contracts\Role, instance of…
Smoky
  • 127
  • 1
  • 2
  • 12
2
votes
1 answer

Call to undefined method Auth::user()->can() in laravel 8 error

I have a problem with determining the permission with Auth::user()->can(). For example Auth::user()->can('trunk.index) returns always error; But I have a problem. If I dump $user->getPermissionsViaRoles(); ,I will get a large result. I'm using…
Nisha Patel
  • 45
  • 11
2
votes
1 answer

How to display separate permission according to role category?

I am new in Laravel development. I am working on roles and permissions in Laravel using Spatie, want to display One title name of permission list e.g I have list of property permissions then want to display Property title name on the top of the…
Ahil Khan
  • 227
  • 1
  • 4
  • 12
2
votes
2 answers

Laravel-permission Undefined type PermissionRegistrar

I'm trying to install the package Laravel-permission v5 for a project in Laravel 8. Following the instructions at the documentation, I runned composer require spatie/laravel-permission and to be able to migrate the permission tables I executed: php…
abelarda
  • 45
  • 1
  • 6
2
votes
1 answer

Laravel reseeding a table

In Laravel how would you reseed a database? Without losing existing data / migrations? I have a RoleAndPermissionSeeder.php with Spatie's Permission package: namespace Database\Seeders; use Illuminate\Database\Seeder; use…
Ronald
  • 69
  • 8
2
votes
1 answer

How to use Laravel @can() in Angular

I have a project that is fully Laravel-8 using Spatie-Permission. Everything is working well. But the team decided to use Laravel-8 as backend and Angular-11 as front-end. Initially, in the pure Laravel, it looks like this: Controller public…
user11352561
  • 2,277
  • 12
  • 51
  • 102
1
2
3
17 18