【发布时间】:2015-04-08 05:11:26
【问题描述】:
如何将中间件与资源一起使用?
Route::resource('myitem', ['middleware' => 'auth', 'uses' => 'App\\Controllers\\MyitemsController']);
刚刚关注https://laracasts.com/discuss/channels/general-discussion/struggling-with-routeresource-and-auth-middleware,可惜没能解决。
得到错误:
ErrorException (E_UNKNOWN)
Array to string conversion
Open: /vendor/laravel/framework/src/Illuminate/Routing/Router.php
protected function getResourceAction($resource, $controller, $method, $options)
{
$name = $this->getResourceName($resource, $method, $options);
return array('as' => $name, 'uses' => $controller.'@'.$method);
}
【问题讨论】:
-
你使用的是 Laravel 4 还是 5?因为标签上写着 4 但中间件是 Laravel 5 中引入的东西......
-
我使用的是 laravel 4。你确定它是 laravel5 的一个特性吗?
-
非常有用的问题。我刚开始使用 Laravel 5,文档并不总是很清楚。
标签: authentication laravel laravel-4 middleware