Problem returning multiple routes in laravel

0

I have a route that when accessing www.exemplo.com/comer returns a view with the content. What I am trying to do now and I created another route to do the same effect but when I try to access www.example.com/cesar-sousa does not return the right view returns the view of the first example I gave above.

Basically I want to know how I can create routes to access several different views but with the position of the domain always the same.

Example

www.exemplo.com/comer ->EstabelecimentosController@estabelecimentos
www.exemplo.com/cesar-sousa -> PerfilUserController@perfil_user

I want something like this to always position the bar, but depending on the slug that is stored in the database, return the right controller and the right view.

Routes

Route::get('{slug_user_perfil}', 'PerfilUserController@perfil_user');
Route::get('{slug_categoria}', 'EstabelecimentosController@estabelecimentos');

And more or less this I have the slugs stored in the database I intend that depending on the slug presented in the URL it knows what controller it has to use and by itself will return the correct view because I put two routes with parameter slug but when I try to access the users slug it always returns the controller of the categories that in itself returns the view of the categories and that is my problem

    
asked by anonymous 02.06.2017 / 00:47

1 answer

0

If I understood the question well, just create a function to test what was passed as a parameter:

Route::get('/{param?}', function ($param="default") {
    if( $param == "default")
        return view('welcome')
    else if( $param == "comer")
        return view('comer')
    return view('cesar-sousa');
});
    
02.06.2017 / 02:20