En Laravel 8.
CodePudding user response:
The following may work for you
public function edit($id){
// other codes and logics
if($userRole === 'Admin'){
// let him edit
}
else {
// redirect back
}
Note : make sure $userRole is a string not array. if its a array specify its array index like $userRole[0] == 'Admin'
CodePudding user response:
Use \Auth::user()->role to get role type and then if else
public function edit($id){
// other codes and logics
if(\Auth::user()->role === 'Admin'){
// let him edit
}
else {
// redirect back
}