Dynamic Routes for Laravel pages

0

I want to create a dynamic route system without having to code gambiarras.

Come on.

I have the Routes:

Route::group([
    'middleware' => ['web'],
    'namespace' => 'LaraShop\Front\Http\Controllers',
    'as' => 'page'
], function()
{
    /*
     * Páginas padrão
     */
    Route::get('/', 'HomeController@index')->name('.home');
    Route::get('/contato', 'PagesController@show')->name('.contact');

    /*
     * Rotas Dinâmicas
     */
    Route::get('{page}', 'PagesController@getPage');

});

Route::group([
    'middleware' => ['web', 'auth'],
    'namespace' => 'LaraShop\Admin\Http\Controllers',
    'as' => 'admin'
], function() {
    // rotas do admin
});

The question is, what is the best way for {page} to go through route / admin without causing an error?

    
asked by anonymous 04.08.2017 / 15:43

1 answer

0

Position your route at the end of the file.

Route::get('{page}', 'PagesController@getPage');

No PageController@getPage , check which page it is and if it has view for example and if it does not find abort(404)

    
04.08.2017 / 19:45