mardi 8 octobre 2019

Laravel how to check if url param is in array otherwise use general router

I'm using router in Laravel and my routes file is like this

Route::get('/{product_slug}', 'HomeController@subpage');
Route::get('/login', 'AuthController@login');
Route::get('/signup', 'AuthController@signup');

Route::get('/products', 'HomeController@products');
Route::get('/product/{product_id}', 'HomeController@product_detail');

if /{product_slug} is in array ('product_a', 'product_b') use HomeController@subpage but if not use following route.

for example,

If user enter www.sample.co/product_a it will use HomeController@subpage

but if user enter www.sample.co/signup it will use AuthController@signup

how can I setup the routes.

Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire