jeudi 11 octobre 2018

Custom slug (URL) in Laravel (using htaccess is an option)

I have routes like this coming from the database

$cat_routes = App\User::list_routes();

foreach ($cat_routes as $route){
    Route::get('/category/{'.$route->route.'}', CategoriesController@getCategoryByRoute');
}

To access this category the URL will be:

domain.com/category/cars (or any category rather than cars)

Is there anyway to create custom URL or slug to change the URL like this:

domain.com/cars (clothes, women, watches .... etc)

Without the word category and the controller like this:

public function getCategoryByRoute($category_route)

From Laravel or htaccess?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire