简体   繁体   English

Laravel 5新路线不起作用

[英]Laravel 5 new routes don't work

I'm starting with laravel 5 framework and I have a problem with the routes. 我从laravel 5框架开始,我的路线有问题。

In the last few days, the routes worked correctly, but today I added a new route and it doesn't work anymore. 在最近几天,路线工作正常,但今天我添加了一条新路线,它不再起作用了。

I have these routes 我有这些路线

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']);

All work correctly, but I added this new route 一切正常,但我添加了这条新路线

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

and I call it like this 我称之为这样

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

I tried php artisan route:clear, php artisan route:cache and php artisan route:list, and the new route appear in the list: 我尝试了php artisan route:clear,php artisan route:cache和php artisan route:list,新路由出现在列表中:

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

The other routes work correctly and I think that it is a cache problem, because if I change the url/create to url/create2, and I change it in the template to url/create2 it doesn't work. 其他路由正常工作,我认为这是一个缓存问题,因为如果我将url / create更改为url / create2,并且我在模板中将其更改为url / create2则不起作用。

Thanks in advance to all 在此先感谢所有人

You should use it as url/filter 你应该将它用作url/filter

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

because you're naming it like this: 因为你这样命名:

'as' =>'url/filter'

Or remove 'as' =>'url/filter' part from route. 或者从路线中删除'as' =>'url/filter'部分。 In this case name of your route will be urls/filter and not url/filter . 在这种情况下,您的路线名称将是urls/filter而不是url/filter

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

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