Laravel 5条新路线不起作用

时间:2016-06-13 16:42:21

标签: php laravel routing

我从laravel 5框架开始,我的路线有问题。

在过去的几天里,路线工作正常,但今天我添加了一条新的路线,它不再适用了。

我有这些路线

Route::get('url/create', 'UrlController@create');
Route::get('url/bulk', 'UrlController@bulk_view');
Route::post('url/bulk', ['as' =>'url/bulk', 'uses' => 'UrlController@bulk']);
Route::get('url/bulk_metrics', 'UrlController@bulk_metrics_view');
Route::post('url/bulk_metrics', ['as' =>'url/bulk_metrics', 'uses' => 'UrlController@bulk_metrics']);
Route::post('url/create', ['as' =>'url/create', 'uses' => 'Urlcontroller@store']);
Route::post('url/update/{id}', ['as' =>'url/update', 'uses' => 'Urlcontroller@update']);
Route::get('urls', ['as' =>'url/list', 'uses' => 'Urlcontroller@index']);
Route::get('url/{id}', ['as' =>'url/show', 'uses' => 'Urlcontroller@show']);
Route::post('url/delete/{id}', ['as' =>'url/delete', 'uses' => 'Urlcontroller@destroy']);

一切正常,但我添加了这条新路线

Route::post('urls/filter', ['as' =>'url/filter', 'uses' => 'Urlcontroller@filter']);

我称之为

{!! Form::open(array('route' => 'urls/filter', 'method' => 'POST')) !!}

我尝试了php artisan route:clear,php artisan route:cache和php artisan route:list,新路由出现在列表中:

 POST     | urls/filter          | url/filter       | App\Http\Controllers\Urlcontroller@filter              | web,auth   |

其他路由正常工作,我认为这是一个缓存问题,因为如果我将url / create更改为url / create2,并且我在模板中将其更改为url / create2,则它不起作用。

提前感谢所有

1 个答案:

答案 0 :(得分:3)

您应该将其用作url/filter

{!! Form::open(array('route' => 'url/filter', 'method' => 'POST')) !!}

因为你这样命名:

'as' =>'url/filter'

或从路线中移除'as' =>'url/filter'部分。在这种情况下,您的路线名称将为urls/filter而不是url/filter