【发布时间】:2021-07-16 06:09:07
【问题描述】:
有什么办法可以在 laravel 8 中定义路由组的名称吗?
我正在尝试为卖家构建前往订单管理网站的路线,以下是我在 web.php
中的路线列表use App\Http\Controllers\Seller\OrderController;
Route::group(['prefix' => 'seller', 'middleware' => 'auth', 'as' => 'seller.', 'namespace' => 'Seller'], function () {
Route::redirect('/','seller/orders');
Route::resource('/orders', [OrderController::class]);
});
错误
ErrorException
Array to string conversion
at C:\wamp64\www\my-project\vendor\laravel\framework\src\Illuminate\Routing\ResourceRegistrar.php:416
412▕ protected function getResourceAction($resource, $controller, $method, $options)
413▕ {
414▕ $name = $this->getResourceRouteName($resource, $method, $options);
415▕
➜ 416▕ $action = ['as' => $name, 'uses' => $controller.'@'.$method];
417▕
418▕ if (isset($options['middleware'])) {
419▕ $action['middleware'] = $options['middleware'];
420▕ }
1 C:\wamp64\www\my-project\vendor\laravel\framework\src\Illuminate\Routing\ResourceRegistrar.php:416
Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Array to string conversion", "C:\wamp64\www\my-project\vendor\laravel\framework\src\Illuminate\Routing\ResourceRegistrar.php", ["orders", "index", "orders.index"])
2 C:\wamp64\www\my-project\vendor\laravel\framework\src\Illuminate\Routing\ResourceRegistrar.php:189
Illuminate\Routing\ResourceRegistrar::getResourceAction("orders", "index", [])
【问题讨论】: