Route parameters allow dynamic values to be captured from a URL.
Example:
Route::get('/products/{id}', function ($id) {
return $id;
});
For /products/25, id is 25.
Parameters can be constrained:
Route::get('/products/{id}', ...)->whereNumber('id');
Optional parameters can be written using ? when appropriate:
Route::get('/user/{name?}', ...);
Scenario:
An admin application may use /orders/{order} to identify an order. Route parameters are useful for resource-oriented URLs and become more powerful when combined with implicit model binding.
0 comments:
Post a Comment
Thanks