I used this routes for either Laravel 5.1 and Laravel 5.3, and now when I'm using this type of route order it gives me the title error hope you can help me, you can find the code here :
Route::prefix('productos')->group(function () {
'as' => 'products.index',
'uses' => 'ProductController@index'
Route::get('crear',[
'as' => 'products.create',
'uses' => 'ProductController@create'
]);
Route::post('guardar',[
'as' => 'products.store',
'uses' => 'ProductController@store'
]);
// Editar, borrar
Route::get('{id}',[
'as' => 'products.destroy',
'uses' => 'ProductController@destroy'
]);
Route::get('{id}/editar',[
'as' => 'products.edit',
'uses' => 'ProductController@edit'
]);
Route::put('{id}',[
'as' => 'products.update',
'uses' => 'ProductController@update'
]);
});
To use =>
you need to be in the context of an associative array in php. In your case you are using it inside a closure:
Route::prefix('productos')->group(function () {
// This section is incorrect
'as' => 'products.index',
'uses' => 'ProductController@index'
// Because is not inside an array
Route::get('crear',[
'as' => 'products.create',
'uses' => 'ProductController@create'
]);
...
If I had to guess what you are looking for something like this:
Instead of
'as' => 'products.index',
'uses' => 'ProductController@index'
You should have something like:
Route::get('listar',[
'as' => 'products.index',
'uses' => 'ProductController@index'
]);
So the endpoint would be productos/listar
.
Hope this helps you.