A route parameter
Take your time, follow the code and check your understanding.
The codeLaravel routing and validation
Route::get("/products/{product}", function (string $product) {
return ["id" => $product];
});
// GET /api/products/7 in routes/api.phpYour answer4 min · no timer
Show solution and explanation
A route placeholder supplies its matched segment to the handler. A typed Eloquent model would enable model binding, but this example uses a string.
The placeholder supplies the value 7 to the handler.