Answer the question
In order to leave comments, you need to log in
What is the best way to organize routing with pages of the same type?
I've only been in Laravel for a couple of days, I work with a ready-made layout, and the site has pages like "Contacts", "Details", "Photos" - that is, pages of the same type, static. Somehow I think that for all of them to write something like this:
Route::get('photos', '[email protected]');
Route::get('contacts', '[email protected]');
Answer the question
In order to leave comments, you need to log in
If you can have many of the same type of static pages, then make a separate route for them:
The user will follow the site.com/page/photos link , and you will pull the photos page from the database.
As stated above, page/{section}, adding to the route the condition where('section', '(photos|contacts|other_static_page)');
In the controller, you can safely return view('pages.' . $section);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question