Answer the question
In order to leave comments, you need to log in
How to display all permissions for one role and check if the role is activated?
Good afternoon. For my project I use this package: github for permissions and roles.
The essence of the task is as follows:
We go into the editor of a thread of the role. All rights that exist should be displayed there. There are no problems in this part. Next, the most difficult thing for me is to check whether this permission is activated for this role or not.
Controller code :
public function edit(int $id){
if(auth()->user()->hasPermissionTo('admin.roles.edit')){
$role = Role::with('permissions')->find($id);
$permissions = Permission::all();
dd($role);
Breadcrumbs::addBreadcrumb('Роль: "' . $role->title . '"', route('admin.roles'));
return view('admin.roles.edit', compact('role', 'permissions'));
}else{
flash('У вас не достаточно прав!')->warning();
return redirect()->intended(route('admin.roles'));
}
}
@foreach($permissions as $permission)
{{ Form::checkbox('permissions[]', $permission->id ) }}
{{ Form::label($permission->name, $permission->name) }}<br>
@endforeach
Answer the question
In order to leave comments, you need to log in
From documentation:
It's not clear from the question what exactly is causing the problem, so I can't give a more precise answer.
Status:
@if(Auth::user()->odmen == '1') <h>ADMIN</h> @endif
@if(Auth::user()->yb == '1' && Auth::user()->odmen == '0') <h>YOUTUBER</h>
@endif
@if(Auth::user()->yb == '1' && Auth::user()->premium == '1' )
@endif
@if(Auth::user()->yb == '1' && Auth::user()->odmen == '1' )
@endif
@if(Auth::user()->premium == '1' && Auth::user()->odmen == '0' && Auth::user()->yb == '0' ) <h>PREMIUM</h>
@endif
@if(Auth::user()->premium == '0' && Auth::user()->odmen == '0' && Auth::user()->yb == '0' ) <h>USER</h>
@endif
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question