【发布时间】:2021-06-04 05:23:46
【问题描述】:
我正在创建一个我想用来管理员工数据的后端页面(使用 laravel 5.8)。我在指向员工概览页面的侧边菜单刀片上添加了一个链接。
链接:
<li class="nav-item">
<a href="{{ action('Profiles\Controllers\EmployeeController@index') }}"
class="nav-link {{ Request::is('admin') ? 'active' : null }}">
<i class="fas fa-user"></i> Employees
</a>
</li>
我还制作了一个控制器来获取我想要显示的数据,目前在函数中使用 dd()。
class EmployeeController extends Controller
{
public $model = CustomerLogin::class;
protected $views = 'WebshopCustomers::customerslogins ';
static $routes = ['index', 'create', 'store', 'edit', 'update', 'destroy'];
protected $datatableSelect = 'customer_logins';
protected $datatableRelations = ['roles', 'permissions'];
protected $datatableTrashed = true;
protected $datatableRawColumns = ['email', 'deleted_at'];
public function baseBreadcrumbs()
{
return [
['name' => 'Gebruikersbeheer']
];
}
public function index()
{
dd('test_index');
}
}
重新加载后页面显示以下错误:
错误异常(E_ERROR): Action App\Modules\Profiles\Controllers\EmployeeController@index 未定义。 (查看:C:\xampp\htdocs\shopname\app\Modules\Backend\Views\partials\sidebar-default.blade.php)
路线: 我用谷歌搜索了这个错误并阅读了检查该函数的路由是否存在(它不存在)的建议,所以我添加了它。
Route::get('/', 'EmployeeController@index')->name('employeeprofiles.index');
还提到了在 RouteServiceProvider 中将 $namespace 的值更改为 null,将其设置为 null 并没有改变我代码的当前行为。
我该如何纠正这个问题,我还可以检查哪些其他事项?
【问题讨论】:
标签: php laravel laravel-blade