1
I’m getting the following error by clicking on permissions, button that directs to this controller:
Error:
Undefined Property: App Http Controllers Rolescontroller::$role
Controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Role;
class RolesController extends Controller
{
//Exibe Lista de Roles
public function ListRoles(role $role)
{
$roles = $role->all();
return view('Roles/roles', compact('roles'));
}
//Exibe Formulário de edição
public function edit($idRole)
{
$role = role::find($idRole);
if(empty($role)){
return view('alert');
}
return view('Roles/roles-update', compact('role'));
}
//Salva alterações do formulário de edição
public function save($idRole)
{
$name = Request()->input('name');
$label = Request()->input('label');
$role = role::find($idRole);
$role->name = $name;
$role->label = $label;
$role->save();
return redirect()->action('RolesController@ListRoles')->withInput();
}
//Deletar uma Role
public function delete($idRole)
{
$role = role::find($idRole);
$role->delete();
return redirect()->action('RolesController@ListRoles');
}
//enviar permissao da role para a view de permissao da role
public function permissions($id)
{
$role = $this->role->find($id);
$permissions = $role->permissions;
return view('roles/permissions', compact('role', 'permissions'));
}
}
RESOLVED:
public function permissions($idRole)
{
$role = role::find($idRole);
$permissions = $role->permissions;
return view('roles/permissions', compact('role', 'permissions'));
}
The error is basically telling you that the method/property
role
does not exist. Check if this is present in the controller.– Leandro Lima
Role method is present
– João.Mistura
I can publish the entire controller if it helps
– João.Mistura
Help yes. Put the whole code to facilitate understanding.
– David Alves
I just didn’t think right, but you can understand
– João.Mistura
the error is specified that occurs on line 61, ie where I had shown
– João.Mistura