如何解决laravel 5.3中未定义的路由? [英] How to solve route not defined in laravel 5.3?
问题描述
public function store(CreateUserRequest $ request)
{
$ input = $ request-> all();
$ user = $ this-> userRepository-> create($ input);
Flash :: success('User saved successfully。');
return redirect(route('user.index。'。$ input ['year']));
}
存在这样的错误:
InvalidArgumentException在UrlGenerator.php中行314:路由
[users.index.2016]未定义。
出现错误时,网址如下所示: http:// localhost / mysystem / public / users
My routes\web.php是这样的:
Route :: get('users / index / {year}','UserController @ index') - > name('users.index.year');
Route :: get('users / create / {year}','UserController @ create') - > name('users.create.year');
Route :: resource('users','UserController');
我想让url看起来像这样: http:// localhost / mysystem / public / users / index / 2016
有没有人可以帮助我?
您应该致电 route()
函数为:
route('users。 index.year',['year'=> $ year])
My controller code is like this :
public function store(CreateUserRequest $request)
{
$input = $request->all();
$user = $this->userRepository->create($input);
Flash::success('User saved successfully.');
return redirect(route('user.index.'.$input['year']));
}
There is exist error like this :
InvalidArgumentException in UrlGenerator.php line 314: Route [users.index.2016] not defined.
When error, the url look like this : http://localhost/mysystem/public/users
My routes\web.php is like this :
Route::get('users/index/{year}', 'UserController@index')->name('users.index.year');
Route::get('users/create/{year}', 'UserController@create')->name('users.create.year');
Route::resource('users', 'UserController');
I want the url look like this : http://localhost/mysystem/public/users/index/2016
Is there any people who can help me?
You should call the route()
function as:
route('users.index.year', ['year' => $year])
这篇关于如何解决laravel 5.3中未定义的路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!