Answer the question
In order to leave comments, you need to log in
How to pass url part in laravel controller?
Guys tell me how to do it: I have a url like /api/v1/products/category/sub-data-1/sub-data-2/sub-data-n
I need to use the controller at /api/v1/products/ and then pass the rest of the url category/sub-data-1/sub-data-2/sub-data-n to the controller for processing.
I actually tried to do it like this
Route::get('products/{slug}', '[email protected]')->where(['slug' => '^(.*?)$/']);
Answer the question
In order to leave comments, you need to log in
Try the following option, in my case everything after products/* is captured
Route::get('products/{any}', '[email protected]')->where('any', '.*');
/api/v1/products/category?id=1 // Получаем определенную категорию
/api/v1/products?category_id=1 // Получаем товар с определенной категорией
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question