Answer the question
In order to leave comments, you need to log in
How to design a route?
You need to achieve the following result:
/yarn/
/yarn/alize/
/yarn/alize/lana-gold
/yarn/
/yarn/{manufacturer}/
/yarn/{manufacturer}/{collection}
class YarnController extends Controller
{
public function index()
{
return 'index()';
}
public function show($manufacturer, $collection = null)
{
if ($collection) {
$test = $manufacturer .', '. $collection;
} else {
$test = $manufacturer;
}
return $test;
}
}
Route::group(['prefix' => 'yarn'], function() {
Route::get('/', [YarnController::class, 'index']);
Route::get('/{manufacturer}/{collection?}', [YarnController::class, 'show']);
});
// /yarn/{country}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question