简体   繁体   English

路由问题-Laravel

[英]Facing an issue with routing - Laravel

I started working with Laravel last week and I'm facing a minor problem with routes. 上周,我开始与Laravel合作,但现在我遇到了路线方面的一个小问题。

when i do the following: 当我执行以下操作时:

Route::group(array('before' => 'auth'), function() {
    Route::resource('admin', 'VacatureController');
    Route::get('admin/test', array('uses' => 'VacatureController@create'));
    Route::post('admin/test', array('uses' => 'VacatureController@store'));
});

and i go to admin/test , i get an empty page. 我去admin/test ,我得到一个空白页。

when i change admin/test to something like test/test like: 当我将admin/test更改为test/test类的内容时:

Route::group(array('before' => 'auth'), function() {
    Route::resource('admin', 'VacatureController');
    Route::get('test/test', array('uses' => 'VacatureController@create'));
    Route::post('test/test', array('uses' => 'VacatureController@store'));
}); 

it works fine. 它工作正常。 I looked itup in the documentation, but i didn't become anything wiser. 我在文档中查找了它,但是并没有变得更明智。 Can someone please enlighten me? 有人可以启发我吗?

Try putting the Route::resource as the last route. 尝试将Route::resource作为最后一条路线。 Laravel will try all routes in the order you put them in the route file, so when you put the resource route first only this one will be checked because it expects all admin routes to be there. Laravel将按照您将所有路由放入路由文件的顺序尝试所有路由,因此当您首先放置资源路由时,将仅选中该路由,因为它期望所有管理路由都在那儿。

Route::group(array('before' => 'auth'), function() {
    Route::get('admin/test', array('uses' => 'VacatureController@create'));
    Route::post('admin/test', array('uses' => 'VacatureController@store'));
    Route::resource('admin', 'VacatureController');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM