I am using Laravel 5 and you need to make a wildcard pattern by sending the user to different controllers based on the type of URL pulled from the database.
I need to check the URL pool in the database and then load the appropriate controller / method based on the slug type stored in the database. I am struggling with the last part, which sends the user to the appropriate controller. Below is my route:
Route::any('{slug}', function($slug){ $url = \App\Url_slug::where('url_slug', $slug)->first(); if($url->count()){ switch($url->url_type){ case 'product': // SEND USER TO PRODUCT CONTROLLER break; case 'category': // SEND USER TO CATEGORY CONTROLLER break; case 'page': // SEND USER TO PAGE CONTROLLER break; } } else { abort(404); } });
What do I need to replace comments in order to send the user to the appropriate controller?
source share