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
1 answer

Laravel Spatie Permission Multi Models to Permission

I know how to assign permissions to user. class User extends Authenticatable { use HasRoles; } $user->givePermissionTo('edit articles'); In this case, in model_has_permissions table will be inserted like this. permission_id=>…
LoveCoding
  • 1,121
  • 2
  • 12
  • 33
1
vote
0 answers

Laravel user permissions are assigned to the model instead of the specific user (spatie / laravel-permission)

UPDATE - SOLUTION I opened an issue on their github page: https://github.com/spatie/laravel-permission/issues/1398#issuecomment-594032058 All I had to do is change the change the 'model_morph_key' type, in the migrations, to mach the type of my…
1
vote
1 answer

Catching exceptions when calling role::create and permission::create

I am using laravel permissions and i am creating and destroying permissions a lot and sometimes i cant tell if a user has a certain permission or don't and having to check if a user has a role and permission shall require additional code before i…
Gandalf
  • 1
  • 29
  • 94
  • 165
1
vote
1 answer

How to remove permission from a role only for a particular user in spatie/laravel-permission?

Let's say that I have three users in my system Sam, John and Sarah. All three have a role of editor which gives them permission to create article, edit article, publish article and delete article. Now for some reason, I don't want Sam to have…
DP101
  • 183
  • 4
  • 11
1
vote
0 answers

Laravel spatie permission assign super admin with multiple guards

what: i want to assign all permissions for each guard' i have three guards unit, pack and troop, each has the same permissions assigned create, edit, delete, and view, for a set feature. I was using this to set all permissions when only using a…
DEVeasey
  • 41
  • 2
1
vote
0 answers

Spatie User Permissions - Belongs To Many Companies, solution feedback

I have a situation where a user can belong to many teams/companies and within that team/company they can have different roles and permissions depending on which one they are signed into. I have come up with the following solution and would love some…
Adam Lambert
  • 1,311
  • 3
  • 24
  • 45
1
vote
1 answer

Laravel Spatie unable to restrict UserController

Currently I have users.index blade which I would like to restrict. However, I failed to restrict it. I have tried to create another test blade and a TestController and I have set permission to it and it works fine. However with UserController, there…
1
vote
1 answer

Laravel - How to ensure that logged in user can only access his company data

I am developing a client portal application using Angular-7 as frontend and Laravel-5.8. I am using Larave Spatie for User Management. I have these three tables: CREATE TABLE `company` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY…
ayobamilaye
  • 429
  • 2
  • 10
  • 25
1
vote
1 answer

spatie/laravel-permissions - Gate and hasPermissionTo are not working

I have a problem with spatie/laravel-permissions... I use Gate in AuthServiceProvider.php to define Superadmin (can bypass all permissions without register it to the role)... It is working perfectly with can('the-permission') helper. But it is not…
Syamsoul Azrien
  • 2,534
  • 4
  • 32
  • 55
1
vote
1 answer

How to populate the select opition from Database - Spatie Permission package - Laravel

I was following the article to bring up front end UI for Spatie/permissions. article I was able to understand every part but I cant understand a specific portion, Please navigate to the Roles Part, (please search for 'roles.edit', it will take…
mightyteja
  • 825
  • 1
  • 14
  • 38
1
vote
0 answers

Laravel Users and Polymorphism

Currently using the standard users auth for Laravel (php artisan make:auth) and then combining it with spatie/laravel-permission. My question is as follows, I have different types of users Students Bursary Administrators Bursary Providers Super…
SupaMonkey
  • 876
  • 2
  • 9
  • 25
1
vote
0 answers

Access Controller resources based on Laravel/Spatie Permissions

I am working on Laravel passport api in which i am using spatie package for user role's and permission's. I have to perform certain operation ('store','view','update','delete') based on user permission's. For this purpose i have created a trait and…
Amir Khan
  • 183
  • 2
  • 16
1
vote
1 answer

Hide model fields based on user permissions

Lets say user_one has permission to view purchase_price, and user_two does not have this permission. I want to dynamically hide the purchase_price based on the user permission. What I have done I already managed the permissions using spatie…
AE1995
  • 372
  • 5
  • 17
1
vote
0 answers

Setting user permission to access resources laravel spatie

I'm attempting to limit access to a specific resource HealthController I am using Spatie and Laravel. I have set up my routes such as this. Note the posts route works fine, but the health one does not do as I want. Routes: Route::group(…
user5067291
  • 440
  • 1
  • 6
  • 16
1
vote
1 answer

How can I extend the authentication built into Laravel to handle authorization in controller constructors?

I have a Laravel application using the built-in basic Laravel auth, but in addition to being able to authenticate users, I also need to be able to do things like check permissions and authorize them for given controller actions as well as do things…
HartleySan
  • 7,404
  • 14
  • 66
  • 119