Problem with route resource

0

I have the following structure in the routes:

Route::group(['prefix' => 'ventas', 'as' => 'ventas.'], function () {
    //INICIO
    Route::group(['namespace' => 'Inicio'], function() {
        Route::get('inicio', [
            'as' => 'inicio',
            'uses' => 'InicioController@index'
        ]);
    });
});

and in the view I call this route like this: href="{{route('ventas.inicio')}}"

Now if I want to add the Route :: resource instead of the previous one, that same route does not work for me.

Route::group(['prefix' => 'ventas', 'as' => 'ventas.'], function () {
    //INICIO
    Route::group(['namespace' => 'Inicio'], function() {
         Route::resource('inicio', 'InicioController');    
    });
});
    
asked by Juan Pablo B 06.01.2017 в 15:20
source

2 answers

2

Hello @Juan Pablo in the resource you do not need to add an alias with '.' because this is what should be generating a route like 'ventas.ventas.index', remove that alias and work perfectly I attached an image with the list of routes that I generated when doing the exercise, I hope you serve, greetings

    
answered by 06.01.2017 / 19:11
source
5

When you use resouce laravel that creates the necessary routes to perform a CRUD

Route::resource('inicio','InicioController');

The routes generated would be:

  • home.create
  • home.destroy
  • home.show
  • home.update
  • home.edit

but if you want to generate another route with an alias it would be:

Route::get('inicio',[
    'uses' => 'InicioController@index',
    'as'   => 'inicio'
]);
    
answered by 28.01.2017 в 04:01