Javier Javier - 2 years ago 291
PHP Question

Laravel 5 new routes dont work

Im starting with laravel 5 framework and i have a problem with the routes.

In the last days, the routes worked correctlly, but today i added a new route and it dont work.

I have this 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 correctlly, 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:

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

The other routes work correctlly and i think that 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 dont work.

Thanks in advance to all

Answer Source

You should use it as 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. In this case name of your route will be urls/filter and not url/filter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download