From 9858f8aa61705ea87a36ab34ae4774da4b5180bb Mon Sep 17 00:00:00 2001 From: niallobrien Date: Wed, 27 Jun 2012 14:19:21 +0200 Subject: [PATCH 01/10] Added examples for using $errors in views. --- laravel/documentation/validation.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/laravel/documentation/validation.md b/laravel/documentation/validation.md index 4da4683c..690bd54e 100644 --- a/laravel/documentation/validation.md +++ b/laravel/documentation/validation.md @@ -304,7 +304,26 @@ Once you have performed your validation, you need an easy way to get the errors Great! So, we have two simple registration routes. One to handle displaying the form, and one to handle the posting of the form. In the POST route, we run some validation over the input. If the validation fails, we redirect back to the registration form and flash the validation errors to the session so they will be available for us to display. -**But, notice we are not explicitly binding the errors to the view in our GET route**. However, an errors variable will still be available in the view. Laravel intelligently determines if errors exist in the session, and if they do, binds them to the view for you. If no errors exist in the session, an empty message container will still be bound to the view. In your views, this allows you to always assume you have a message container available via the errors variable. We love making your life easier. +**But, notice we are not explicitly binding the errors to the view in our GET route**. However, an errors variable ($errors) will still be available in the view. Laravel intelligently determines if errors exist in the session, and if they do, binds them to the view for you. If no errors exist in the session, an empty message container will still be bound to the view. In your views, this allows you to always assume you have a message container available via the errors variable. We love making your life easier. + +For example, if email address validation failed, we can look for 'email' within the $errors session var. + + $errors->has('email') + +Using Blade, we can then conditionally add error messages to our view. + + {{ $errors->has('email') ? 'Invalid Email Address' : 'Condition is false. Can be left blank' }} + +This will also work great when we need to conditionally add classes when using something like Twitter Bootstrap. +For example, if the email address failed validation, we may want to add the "error" class from Bootstrap to our *div class="control-group"* statement. + +
+ +When the validation fails, our rendered view will have the appended *error* class. + +
+ + ## Custom Error Messages From f640cd42ad9283db82d7c7339ff1a1e050232dcf Mon Sep 17 00:00:00 2001 From: Daniel Petrie Date: Wed, 27 Jun 2012 11:15:34 -0700 Subject: [PATCH 02/10] adding in '=' to regex for (:any) / (:any?) calls. --- laravel/routing/router.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/routing/router.php b/laravel/routing/router.php index a6577b3f..91957551 100644 --- a/laravel/routing/router.php +++ b/laravel/routing/router.php @@ -75,7 +75,7 @@ class Router { */ public static $patterns = array( '(:num)' => '([0-9]+)', - '(:any)' => '([a-zA-Z0-9\.\-_%]+)', + '(:any)' => '([a-zA-Z0-9\.\-_%=]+)', '(:all)' => '(.*)', ); @@ -86,7 +86,7 @@ class Router { */ public static $optional = array( '/(:num?)' => '(?:/([0-9]+)', - '/(:any?)' => '(?:/([a-zA-Z0-9\.\-_%]+)', + '/(:any?)' => '(?:/([a-zA-Z0-9\.\-_%=]+)', '/(:all?)' => '(?:/(.*)', ); From 14e9488cf9faac9ac573b4b7dd5bd588baafd9c8 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 28 Jun 2012 15:19:17 -0500 Subject: [PATCH 03/10] Speed up eager loading of many to many. --- .../relationships/has_many_and_belongs_to.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/laravel/database/eloquent/relationships/has_many_and_belongs_to.php b/laravel/database/eloquent/relationships/has_many_and_belongs_to.php index 52276a5f..28e8c19f 100644 --- a/laravel/database/eloquent/relationships/has_many_and_belongs_to.php +++ b/laravel/database/eloquent/relationships/has_many_and_belongs_to.php @@ -325,14 +325,21 @@ class Has_Many_And_Belongs_To extends Relationship { { $foreign = $this->foreign_key(); + $dictionary = array(); + + foreach ($children as $child) + { + $dictionary[$child->pivot->$foreign][] = $child; + } + foreach ($parents as &$parent) { - $matching = array_filter($children, function($v) use (&$parent, $foreign) - { - return $v->pivot->$foreign == $parent->get_key(); - }); + $parent_key = $parent->get_key(); - $parent->relationships[$relationship] = array_values($matching); + if (isset($dictionary[$parent_key])) + { + $parent->relationships[$relationship] = $dictionary[$parent_key]; + } } } From d53ac0e9d128124d294d476c5102666bb330c1a6 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 28 Jun 2012 15:28:03 -0500 Subject: [PATCH 04/10] update change log --- laravel/documentation/changes.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/laravel/documentation/changes.md b/laravel/documentation/changes.md index d4e12daa..e5c68b89 100644 --- a/laravel/documentation/changes.md +++ b/laravel/documentation/changes.md @@ -2,6 +2,8 @@ ## Contents +- [Laravel 3.2.4](#3.2.4) +- [Upgrading From 3.2.3](#upgrade-3.2.4) - [Laravel 3.2.3](#3.2.3) - [Upgrading From 3.2.2](#upgrade-3.2.3) - [Laravel 3.2.2](#3.2.2) @@ -31,6 +33,16 @@ - [Laravel 3.1](#3.1) - [Upgrading From 3.0](#upgrade-3.1) + +## Laravel 3.2.4 + +- Speed up many to many eager loading mapping. + + +## Upgrading From 3.2.3 + +- Replace the **laravel** folder. + ## Laravel 3.2.3 From 750365c74008b5c1715ff2e9731514355f32e810 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 28 Jun 2012 15:28:26 -0500 Subject: [PATCH 05/10] increment version --- artisan | 2 +- paths.php | 2 +- public/index.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/artisan b/artisan index e5dfd7ef..bd0f3cbb 100644 --- a/artisan +++ b/artisan @@ -4,7 +4,7 @@ * Laravel - A PHP Framework For Web Artisans * * @package Laravel - * @version 3.2.3 + * @version 3.2.4 * @author Taylor Otwell * @link http://laravel.com */ diff --git a/paths.php b/paths.php index 78d5a02f..e5a6a055 100644 --- a/paths.php +++ b/paths.php @@ -3,7 +3,7 @@ * Laravel - A PHP Framework For Web Artisans * * @package Laravel - * @version 3.2.3 + * @version 3.2.4 * @author Taylor Otwell * @link http://laravel.com */ diff --git a/public/index.php b/public/index.php index 00cb86cd..fb2a1902 100644 --- a/public/index.php +++ b/public/index.php @@ -3,7 +3,7 @@ * Laravel - A PHP Framework For Web Artisans * * @package Laravel - * @version 3.2.3 + * @version 3.2.4 * @author Taylor Otwell * @link http://laravel.com */ From 3a504cfa8e8664dbf8ccdc59b4cfc085af7b0d3d Mon Sep 17 00:00:00 2001 From: TommyC81 Date: Fri, 29 Jun 2012 20:34:00 +0300 Subject: [PATCH 06/10] Fixed small typo. --- laravel/documentation/install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/documentation/install.md b/laravel/documentation/install.md index b3312366..51a727d4 100644 --- a/laravel/documentation/install.md +++ b/laravel/documentation/install.md @@ -40,7 +40,7 @@ If you are having problems installing, try the following: - Make sure the **public** directory is the document root of your web server. (see: Server Configuration below) - If you are using mod_rewrite, set the **index** option in **application/config/application.php** to an empty string. -- Verify that your storage folder and the folders within in are writable by your web server. +- Verify that your storage folder and the folders within are writable by your web server. ## Server Configuration: Why Public? From 837f6176272e8599ad689b2c10cbe610d5ecc0a8 Mon Sep 17 00:00:00 2001 From: TommyC81 Date: Fri, 29 Jun 2012 21:42:06 +0300 Subject: [PATCH 07/10] Re-organized and added some more help on the reflash() and keep() functions. --- laravel/documentation/session/usage.md | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/laravel/documentation/session/usage.md b/laravel/documentation/session/usage.md index 5f9aad56..b390b75e 100644 --- a/laravel/documentation/session/usage.md +++ b/laravel/documentation/session/usage.md @@ -5,6 +5,7 @@ - [Storing Items](#put) - [Retrieving Items](#get) - [Removing Items](#forget) +- [Flashing Items](#flash) - [Regeneration](#regeneration) @@ -16,10 +17,6 @@ To store items in the session call the put method on the Session class: The first parameter is the **key** to the session item. You will use this key to retrieve the item from the session. The second parameter is the **value** of the item. -The **flash** method stores an item in the session that will expire after the next request. It's useful for storing temporary data like status or error messages: - - Session::flash('status', 'Welcome Back!'); - ## Retrieving Items @@ -53,6 +50,28 @@ You can even remove all of the items from the session using the **flush** method Session::flush(); + +## Flashing Items + +The **flash** method stores an item in the session that will expire after the next request. It's useful for storing temporary data like status or error messages: + + Session::flash('status', 'Welcome Back!'); + +Flash items that are expring in subsequent requests can be retained for another request by using one of the following methods: + +Retain all items for another request: + + Session::reflash(); + +Retain an individual item for another request: + + Session::keep('status'); + +Retain several items for another request: + + Session::keep(array('status', 'other_item')); + + ## Regeneration From 26623c79ed48df79d2315330899e0a20abebd5e3 Mon Sep 17 00:00:00 2001 From: TommyC81 Date: Fri, 29 Jun 2012 21:45:31 +0300 Subject: [PATCH 08/10] Removed empty row. --- laravel/documentation/session/usage.md | 1 - 1 file changed, 1 deletion(-) diff --git a/laravel/documentation/session/usage.md b/laravel/documentation/session/usage.md index b390b75e..d0f8ec31 100644 --- a/laravel/documentation/session/usage.md +++ b/laravel/documentation/session/usage.md @@ -71,7 +71,6 @@ Retain several items for another request: Session::keep(array('status', 'other_item')); - ## Regeneration From 2159596a83ec8ccdf0b8fb220d153b05588d3524 Mon Sep 17 00:00:00 2001 From: TommyC81 Date: Fri, 29 Jun 2012 21:49:54 +0300 Subject: [PATCH 09/10] Bold characters for reflash and keep. --- laravel/documentation/session/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/documentation/session/usage.md b/laravel/documentation/session/usage.md index d0f8ec31..9e6984ca 100644 --- a/laravel/documentation/session/usage.md +++ b/laravel/documentation/session/usage.md @@ -57,7 +57,7 @@ The **flash** method stores an item in the session that will expire after the ne Session::flash('status', 'Welcome Back!'); -Flash items that are expring in subsequent requests can be retained for another request by using one of the following methods: +Flash items that are expring in subsequent requests can be retained for another request by using one of the **reflash** or **keep** methods: Retain all items for another request: From 110078d2af55053f5c24e0fbb2b4115d1687cc36 Mon Sep 17 00:00:00 2001 From: TommyC81 Date: Fri, 29 Jun 2012 21:55:38 +0300 Subject: [PATCH 10/10] Fixed typo --- laravel/documentation/session/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/documentation/session/usage.md b/laravel/documentation/session/usage.md index 9e6984ca..1b5c9d5c 100644 --- a/laravel/documentation/session/usage.md +++ b/laravel/documentation/session/usage.md @@ -57,7 +57,7 @@ The **flash** method stores an item in the session that will expire after the ne Session::flash('status', 'Welcome Back!'); -Flash items that are expring in subsequent requests can be retained for another request by using one of the **reflash** or **keep** methods: +Flash items that are expiring in subsequent requests can be retained for another request by using one of the **reflash** or **keep** methods: Retain all items for another request: