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
1
vote
3 answers

How to get a list of roles with certain permission in Spatie/permission (Laravel)

I am trying to get it by same way i am getting the list of users with a certain Permission, but with role it's not working throwing me Call to undefined method Spatie\Permission\Models\Role::roles() The way i get list of users with a certain…
Ascerx
  • 59
  • 1
  • 9
1
vote
1 answer

I can't get the request value from input value in laravel

UPDATE: So i just found out that $request can only get the input name so i had to change the radiobox form so that the input name must be different So i'm working with roles and permissions in laravel and i'm using spatie package for roles and…
1
vote
4 answers

How to check multiple permission condition in if statement using laravel spatie package?

I need to check condition in if statement for multiple permissions. It is using spatie package from laravel. I use this code below but it seems doesn't work. It can display the output but the output is not correct. It doesn't filter the…
joun
  • 656
  • 1
  • 8
  • 25
1
vote
2 answers

Laravel: is it possible for middleware to accept route input?

What I want to achieve is, I have audience in a few countries. I also have editors in different country. For example, editor in US can only edit & view posts in US, editor in Hong Kong not allowed to view US posts. Route::get('{country}/posts', [ …
Js Lim
  • 3,625
  • 6
  • 42
  • 80
1
vote
1 answer

redirect unauthorized users to another page spatie laravel

I am working on spatie laravel i want to redirecct unthorized users to a specific view on that view it will have a simple button to redirect to back i have tried like this but its giving me error like Symfony \ Component \ Debug \ Exception \…
Pranav Mandlik
  • 644
  • 6
  • 19
  • 45
1
vote
1 answer

In laravel I need to join to models and still use the methods on the first model

So I have the "User" model and "usersetting" model. the "usersettings" model has a column called "users_id" key to link it back to the User Model. I'm using the spatie permissions and role module... So in the Users model I have use…
0
votes
0 answers

Laravel policies using many to many relationships

well, I'm working on a little project in which I'm using Many to Many relationship (users to comments by example). I'm trying to validate something, what if this auth user owns this comment? If I own this model, then I want to be able to modify it…
0
votes
1 answer

Spatie Permissions / Laravel - Assigned Permission to Role, Role to User - Middleware doesn't pick up on permissions

I am using Spatie Permissions for my Laravel app. I have assigned permissions to a role, and the role to a user. When I use $user->getAllPermissions() or $user->getPermissionsViaRoles() it displays them all in JSON format. However, when I am…
0
votes
0 answers

How can i extend spatie/laravel-permissions to be able to specify the model which the permission is related to and the location of the permission

I'm using spatie/laravel-permissions to give permissions to roles in my app to be able to create a model in a specific location, edit a model in a specific location... I want to add an attribute to permissions table called model_type, that…
Elio Bteich
  • 123
  • 1
  • 10
0
votes
0 answers

Laravel multiple user DB tables, models and guards - user resources not showing in the Nova admin panel

I have separated basic users from admins - basic users are in the "clients" table and admins in the "users" table. I'm using Laravel Nova 4 as an admin panel. My auth.php config looks like this: return [ 'defaults' => [ 'guard' =>…
0
votes
1 answer

Laravel Spatie get permissions of admin

In a laravel project using spatie for permissions and roles, I'm facing something pretty strange. When I call : $permissions = $user->getDirectPermissions(); $roles = $user->getRoleNames(); return response() ->json([ …
Enzo
  • 91
  • 6
0
votes
0 answers

laravel gates permission foreach

excuse me, i'm a junior developer and im still learn about laravel gates concept. i have a tables structure like this. Users = id, email, password, role_id. role = id, name, description. permission = id, name, slug. role_permission =…
0
votes
1 answer

Laravel Backpack Permission Manager - Roles/Permissions do not load with custom UserCrudController?

I am using Laravel-permission ^5.10 and Laravel Backpack Permission Manager ^6.0 with Laravel ^10 and Backpack Pro ^1.6. I am using a custom UserCrudController as per the PermissionManager docs where I have essentially copied and very slightly…
waffl
  • 5,179
  • 10
  • 73
  • 123
0
votes
1 answer

Laravel Spartie get users with their roles

I'm trying to create a view for displaying a list of users in the system with their roles in a table but I'm only getting one user returned despite having one super admin and several admins Here is the code I'm using $data =…
The Only Smart Boy
  • 578
  • 19
  • 39