#### Category : roles

I am building an LMS application in laravel. I’ve got a user model and I use spatie/laravel-permission to assign roles/permissions. Suppose I have admin, teacher, tutor, student roles with permissions assigned to each role. A logged in user can have multiple roles, for example a user can have a teacher role AND a tutor role. ..

So currently I’m developing web apps that will have users management and role management (roles using spatie/laravel-permission). it have a lot of roles for example: Root (super admin) Admin Daerah(based on the village) admin unit (based on his working place/unit) Kepala Badan Kepala seksi Staff Citizen Etc. Every user can (and will) have more than ..

So currently I’m developing web apps that will have users management and role management (roles using spatie/laravel-permission). it have a lot of roles for example: Root (super admin) Admin Daerah(based on the village) admin unit (based on his working place/unit) Kepala Badan Kepala seksi Staff Citizen Etc. Every user can (and will) have more than ..

Sorry because my English is weak and I can not speak well!! This is the route I defined on the web.php page : <?php use AppHttpControllersController; use AppHttpControllersGoogleAuthController; use AppHttpControllersProfileController; use AppHttpControllersUrlController; use IlluminateSupportFacadesAuth; use IlluminateSupportFacadesRoute; /* |————————————————————————– | Web Routes |————————————————————————– | | Here is where you can register web routes for your application. ..

lo que busco es implementar un buscador o filtro para que al seleccionar o escribir el nombre del rol, solamente se visualicen ese tipo de usuario. Sourc..

When I’m creating new users and assign them roles and permissions it works fine, but when I assign role using protected route Route::post(‘/excel/upload’, [ExcelController::class,’upload’])->name(‘uploadExcel’)->middleware(‘auth:sanctum’); i get and error: SpatiePermissionExceptionsGuardDoesNotMatch The given role or permission should use guard web instead of sanctum. auth.php ‘defaults’ => [ ‘guard’ => ‘web’, ‘passwords’ => ‘users’, ], ‘guards’ => [ ..

I have a route : Route::get(‘/TransactionHistory’,’[email protected]’); In Controller QuoteController, I have a function as: public function transactionHistory(){ if(Auth::user()->isAdmin()) { $res= DB::table(‘products_products’) ->select(‘users_users.display_name’,’products_products.name’,’products_products.id’,’products_products.user_id’,’products_products.quantity_type’,’buy_product.price’,’buy_product.rating’,’buy_product.mileage_name’,’buy_product.id as buy_id’) ->join(‘buy_product’,’products_products.id’,’=’,’buy_product.product_id’) ->join(‘users_users’,’buy_product.user_id’,’=’,’users_users.id’) ->get(); } else{$u_id=auth()->user()->id; $res= DB::table(‘products_products’) ->select(‘products_products.name’,’products_products.id’,’products_products.user_id’,’products_products.quantity_type’,’buy_product.price’,’buy_product.rating’,’buy_product.mileage_name’,’buy_product.id as buy_id’) ->join(‘buy_product’,’products_products.id’,’=’,’buy_product.product_id’) ->where(‘buy_product.user_id’,’=’,$u_id) ->get();} return view(‘templates::pagetwigs/transaction-history’)->with(‘details’,$res); } On routing the path I got error as :Call to a member function isAdmin() .. Read more I’m currently working on a laravel project "canteen’. I used a plugin named Spatie to create roles permissions system. This plugin has its own tables from migration like roles, permissions, role_has_permissions, model_has_roles and model_has_permissions. picture example inserting roles to an user I want to make roles Admin, Teacher, Student and Seller. Me as Admin can .. Read more I have a table named wallet and a table named User. I want to know how can I use roles and permission of spatie (laravel) to ask a simple questions (in terms of code) Is X user is admin of Y wallet ? or how can I specify that X user is an admin of .. Read more I made a similar question hours ago but it haven’t recieved much answers so that is the reason I’m asking the same but I will try to maybe word it diferently to maybe make it more clear, I only got one answer in that question but it didn’t worked. I’m going to put a link .. Read more Hey I am developing a project where I have roles and permissions for users and I am trying to protect my routes with the help of middleware by defining Gates but it’s showing me 403| Not Authorized. I can’t understand what the actual problem is? Into Category Controller public function addcategory(AdminsRole$adminsroles){ return view(‘add-category’); } ..

class AuthServiceProvider class AuthServiceProvider extends ServiceProvider { /** * The policy mappings for the application. * * @var array */ protected $policies = [ ‘AppModelsNews’ => ‘AppPoliciesNewsPolicy’, // News::class => NewsPolicy::class, ]; /** * Register any authentication / authorization services. * * @return void */ public function boot() {$this->registerPolicies(); Gate::define(‘news_index’, function ($user) { return .. Read more I need to grant access to users with different roles to actions of one resource. I tried the following but no luck in web.php routes file: Route::resource(‘trampas’, ‘TrampaController’)->middleware(‘role:Administrador|Supervisor’); //Access to all actions Route::resource(‘trampas’, ‘TrampaController’)->middleware(‘role:Monitoreador|Coordinador’)->only(‘index’, ‘show’); But when i declare the 2nd line the first in annulled. Same thing happens when it’s declared in the controller’s .. Read more I am facing an issue where I have assigned the permission like add , edit , view , delete to items like post and comments which are further assigned to particular roles like admin, user , editor . lets take an example: A admin(role) can perform permissions say add,edit,delete(permission) on particular item say he can .. Read more Is there any way to work with Spatie roles and permission by indicating different model name not like using user model in Laravel 8? Sourc.. Read more I sent the below value from view to controller: in View: <input type="checkbox" name="Roles[]" value="{{$user->rolesTeams[$i]->pivot}}"/> In Controller: case ‘team-delete’:$input = $request[‘Roles’]; dd($input); Result: array:1 [▼ 0 => "{"user_id":"15","team_id":"2","user_type":"AppUser","role_id":"2"}" ] now How can I make this like: $user = user_id >> which should be 15$team = team_id >> which whould be 2 $role = .. Read more Tell me how you can use 2 roles on 1 route. I am using the Laravel Permission. My routes Route::group([‘middleware’=>[‘role:user_сitisen’]],function(){ Route::get(‘/addcitisens’, [AppHttpControllersCitisenControl::class, ‘index’]); Route::get(‘/citisen/{id}’, [AppHttpControllersCitisenControl::class, ‘show’]); Route::post(‘/citisen/{id}’, [AppHttpControllersCitisenControl::class, ‘update’])->name(‘citisen’); Route::get(‘/destroy/{id}’, [AppHttpControllersCitisenControl::class, ‘destroy’]); Route::post(‘/citisens’, [AppHttpControllersCitisenControl::class, ‘store’]); Route::get(‘/citisens/export’, [AppHttpControllersCitisenControl::class, ‘CitisenExport’]); }); Route::group([‘middleware’=>[‘role:user_avto’]],function(){ Route::get(‘/avtoslist’, [AppHttpControllersAvtosController::class, ‘index’]); Route::get(‘/addavtos’, [AppHttpControllersAvtosController::class, ‘indexAdd’]); Route::post(‘/avtos’, [AppHttpControllersAvtosController::class, ‘store’]); }); Route::group([‘middleware’=>[‘role:admin’]],function(){ Route::get(‘/addcitisens’, [AppHttpControllersCitisenControl::class, ‘index’]); Route::get(‘/citisen/{id}’, .. Read more In my application, I’ve used the Sentinel package for authorization. Now I need an API to retrieve user permissions for an expected JSON structure. expected JSON structure: { "user_id": 3172, "first_name": "Bonny", "last_name": "Hewage", "username": "bonny", "user_roles": [ { "id": 2, "slug": "store-user", "name": "Store User", "permissions": {"user.create":true, "user.update":true} }, { "id": 6, "slug": "mu-supervisor", .. Read more Hi I have the next problem, how can I get the value of a select on my register.blade, when a user register he should be able to select a role, each role has an id and once he clicks on submit button the rol id should be assigned to his rol_id on users database. But .. Read more This is the current code that loads all the users in the database. In the role 1 is admin and 2 are the normal users. So how can I return only the admin whit a role of 1? @foreach ($users as $key =>$user) <tr> <td class="bs-checkbox "><input data-index="0" name="btSelectItem" type="checkbox"></td> <td>{{ $key + 1 .. Read more I am working on a laravel project having role-based access to users like: 1 admin -> all permissions 2 creator -> add, edit and remove members 3 finance -> add fund, update fund the problem is, a user, say "XYZ" has multiple roles like creator and finance and another user "PQR" has only finance by .. Read more I am simply doing what is in the documentation but God knows what the issue is. I have put use HasRoles; in my User Model but again and again, getting this error: Call to undefined method IlluminateDatabaseEloquentBuilder::assignRole() Whenever assigning role in seeder: use AppModelsUser; use IlluminateDatabaseSeeder; use SpatiePermissionModelsPermission; use SpatiePermissionModelsRole; public function run() {$role ..
i’m a laravel beginner and i use laravel-roles from github. I try to do the setup but with the step: php artisan db:seed i get the following error: IlluminateContractsContainerBindingResolutionException Target class [DatabaseSeedersDatabaseSeeder] does not exist. at vendor/laravel/framework/src/Illuminate/Container/Container.php:811 807| 808| try { 809| $reflector = new ReflectionClass($concrete); 810| } catch (ReflectionException $e) { 811| throw new .. Read more I am Try to get User List with their role in laravel 8, for role and permission i am use spatie package (https://spatie.be/docs/laravel-permission/v4/) i am trying to get any data via user it return error following function return error$all_users_with_all_their_roles = User::with(‘roles’)->get(); $all_users_with_all_direct_permissions = User::with(‘permissions’)->get();$user->hasAllRoles(Role::all()); function (https://spatie.be/docs/laravel-permission/v3/basic-usage/basic-usage#eloquent) ERROR : "Call to undefined method AppModelsUser::getAllPermissions()",…} ..