From a9f7aacea9ed9dae3d6673d61dff187fdf83a436 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 14 Jul 2011 11:08:46 -0700 Subject: [PATCH] Edited readme.md via GitHub --- readme.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index a9bdef26..4876ec22 100644 --- a/readme.md +++ b/readme.md @@ -129,7 +129,7 @@ ### Cleaner URLs ## Defining Routes - [The Basics](#routes-basics) -- [Route Wildcards & Parameters](#routes-parameters) +- [Route URI Parameters](#routes-parameters) - [Route Filters](#route-filters) - [Named Routes](#routes-named) - [Organizing Routes](#routes-folder) @@ -160,4 +160,31 @@ ### The Basics > **Note:** The routes.php file replaces the "controllers" found in most frameworks. Have a fat model and keep this file light and clean. Thank us later. +[Back To Top](#top) + + +### Route URI Parameters + +Laravel makes passing URI parameters to your route functions a breeze. Check out this route: + + 'PUT /user/(:num)' => function($id) {} + +Notice the **(:num)** parameter in the URI? This tells Laravel to allow any numeric value in the second segment of the URI, as well as to pass the segment into the method. + +We can also use the **(:any)** parameter to match the segment to any value: + + 'DELETE /product/(:any)' => function($name) {} + +Of course, you are not limited to one parameter: + + 'GET /post/(:num)/(:num)' => function($month, $day) {} + +Sometimes you may wish to make a parameter optional. You can do so by placing a **?** in parameter: + + 'GET /branch/(:any?)' => function($branch = 'master') {} + +If you need more power and precision (or just want to be extra nerdy), you can even use regular expressions: + + 'GET /product/([0-9]+)' => function($id) {} + [Back To Top](#top) \ No newline at end of file