1
votes

I have 3 routes in a laravel project

  • Route::get('/', 'HomeController@index');
  • Route::get('/videos', 'VideoController@index');
  • Route::get('/movies', 'MoviesController@index');

I have created a settings model & migration where the admin can select the home page. Now what I want to achieve is based on the selection, the route should be set as home page.

Eg: If admin selects example.com/videos as Home Page then videos should be accessed on example.com/

2
uhm simply save the route or url to the database, and show it at will? Where is the problem? - Flame

2 Answers

0
votes

You should create a single route with an optional parameter and a HomeController with an index function, the index function should accept a parameter which could either be video,movies then you use a switch case to check if it is video or music or the home route

Route::get('/{data?}', 'HomeController@index');

public function index(Request $request, $data = null){ //use a switch case to check if it is video, or music

}

0
votes

@PuneetKarajagi You can add each of the variables as a parameter to the route. for instance your route for the video will be route('home', ['data' => 'video']); and the route for movies will be route('home', ['data' => 'movies']);