From 75f63847673f241463c00f42134277039b0e38c2 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 30 Mar 2012 08:41:52 -0500 Subject: [PATCH 1/5] fix eloquent->delete bug. --- laravel/database/eloquent/model.php | 13 +++++++++++++ .../relationships/has_many_and_belongs_to.php | 4 +--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index 763cd46f..d9c88396 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -378,6 +378,19 @@ public function save() return $result; } + /** + * Delete the model from the database. + * + * @return int + */ + public function delete() + { + if ($this->exists) + { + return $this->query()->where(static::$key, '=', $this->get_key())->delete(); + } + } + /** * Set the update and creation timestamps on the model. * 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 225f7eb8..7453a02f 100644 --- a/laravel/database/eloquent/relationships/has_many_and_belongs_to.php +++ b/laravel/database/eloquent/relationships/has_many_and_belongs_to.php @@ -125,9 +125,7 @@ public function insert($attributes, $joining = array()) */ public function delete() { - $id = $this->base->get_key(); - - return $this->joining_table()->where($this->foreign_key(), '=', $id)->delete(); + return $this->pivot()->delete(); } /** From 6aaf015cff285fa266589eb45d780bf93f64e236 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 30 Mar 2012 08:43:10 -0500 Subject: [PATCH 2/5] incremented version and change log. --- artisan | 2 +- changes.md | 11 +++++++++++ paths.php | 2 +- public/index.php | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/artisan b/artisan index 68e645ea..6034de07 100644 --- a/artisan +++ b/artisan @@ -3,7 +3,7 @@ * Laravel - A PHP Framework For Web Artisans * * @package Laravel - * @version 3.1.2 + * @version 3.1.3 * @author Taylor Otwell * @link http://laravel.com */ diff --git a/changes.md b/changes.md index 761388b9..f1a3bc51 100644 --- a/changes.md +++ b/changes.md @@ -2,6 +2,8 @@ ## Laravel Change Log ## Contents +- [Laravel 3.1.3](#3.1.3) +- [Upgrading From 3.1.2](#uprade-3.1.3) - [Laravel 3.1.2](#3.1.2) - [Upgrading From 3.1.1](#upgrade-3.1.2) - [Laravel 3.1.1](#3.1.1) @@ -9,6 +11,15 @@ ## Contents - [Laravel 3.1](#3.1) - [Upgrading From 3.0](#upgrade-3.1) + +## Laravel 3.1.3 + +- Fixes **delete** method in Eloquent models. + + + +- Replace the **laravel** folder. + ## Laravel 3.1.2 diff --git a/paths.php b/paths.php index 7d9e1906..729a2697 100644 --- a/paths.php +++ b/paths.php @@ -3,7 +3,7 @@ * Laravel - A PHP Framework For Web Artisans * * @package Laravel - * @version 3.1.2 + * @version 3.1.3 * @author Taylor Otwell * @link http://laravel.com */ diff --git a/public/index.php b/public/index.php index 42b6a438..9f78eb6e 100644 --- a/public/index.php +++ b/public/index.php @@ -3,7 +3,7 @@ * Laravel - A PHP Framework For Web Artisans * * @package Laravel - * @version 3.1.2 + * @version 3.1.3 * @author Taylor Otwell * @link http://laravel.com */ From b72f4e9fd95201dd752c1080d891841153468ec2 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 30 Mar 2012 08:44:56 -0500 Subject: [PATCH 3/5] fix change log. --- changes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changes.md b/changes.md index f1a3bc51..57d2c4f5 100644 --- a/changes.md +++ b/changes.md @@ -17,6 +17,7 @@ ## Laravel 3.1.3 - Fixes **delete** method in Eloquent models. +## Upgrade From 3.1.2 - Replace the **laravel** folder. From d2f35900cd31d03bd15de1f20237af211287e1e9 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 1 Apr 2012 13:48:27 -0500 Subject: [PATCH 4/5] fix where in shortcut and response header casing problem. --- laravel/database/query/grammars/grammar.php | 12 +++++++----- laravel/response.php | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/laravel/database/query/grammars/grammar.php b/laravel/database/query/grammars/grammar.php index b0c06824..50d2b207 100644 --- a/laravel/database/query/grammars/grammar.php +++ b/laravel/database/query/grammars/grammar.php @@ -397,22 +397,24 @@ public function delete(Query $query) * @param array $bindings * @return string */ - public function shortcut($sql, $bindings) + public function shortcut($sql, &$bindings) { // Laravel provides an easy short-cut notation for writing raw WHERE IN // statements. If (...) is in the query, it will be replaced with the - // correct number of parameters based on the bindings. + // correct number of parameters based on the query bindings. if (strpos($sql, '(...)') !== false) { for ($i = 0; $i < count($bindings); $i++) { - // If the binding is an array, we can just assume it's used to - // fill a "where in" condition, so we will just replace the - // next place-holder in the query with the constraint. + // If the binding is an array, we can just assume it's used to fill a + // where in condition, so we'll just replace the next place-holder + // in the query with the constraint and splice the bindings. if (is_array($bindings[$i])) { $parameters = $this->parameterize($bindings[$i]); + array_splice($bindings, $i, 1, $bindings[$i]); + $sql = preg_replace('~\(\.\.\.\)~', "({$parameters})", $sql, 1); } } diff --git a/laravel/response.php b/laravel/response.php index da3ba84f..c9841403 100644 --- a/laravel/response.php +++ b/laravel/response.php @@ -89,7 +89,7 @@ public function __construct($content, $status = 200, $headers = array()) { $this->status = $status; $this->content = $content; - $this->headers = $headers; + $this->headers = array_change_key_case($headers); } /** From bf886f3271984de6526d54c4736767ef0b842a52 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 1 Apr 2012 13:49:56 -0500 Subject: [PATCH 5/5] incrementing version. --- artisan | 2 +- changes.md | 13 +++++++++++++ paths.php | 2 +- public/index.php | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/artisan b/artisan index 6034de07..66a0cc09 100644 --- a/artisan +++ b/artisan @@ -3,7 +3,7 @@ * Laravel - A PHP Framework For Web Artisans * * @package Laravel - * @version 3.1.3 + * @version 3.1.4 * @author Taylor Otwell * @link http://laravel.com */ diff --git a/changes.md b/changes.md index 57d2c4f5..89d246ef 100644 --- a/changes.md +++ b/changes.md @@ -2,6 +2,8 @@ ## Laravel Change Log ## Contents +- [Laravel 3.1.4](#3.1.4) +- [Upgrading From 3.1.3](#upgrade-3.1.4) - [Laravel 3.1.3](#3.1.3) - [Upgrading From 3.1.2](#uprade-3.1.3) - [Laravel 3.1.2](#3.1.2) @@ -11,6 +13,17 @@ ## Contents - [Laravel 3.1](#3.1) - [Upgrading From 3.0](#upgrade-3.1) + +## Laravel 3.1.4 + +- Fixes Response header casing bug. +- Fixes SQL "where in" (...) short-cut bug. + + +## Upgrading From 3.1.3 + +- Replace the **laravel** folder. + ## Laravel 3.1.3 diff --git a/paths.php b/paths.php index 729a2697..152a4f79 100644 --- a/paths.php +++ b/paths.php @@ -3,7 +3,7 @@ * Laravel - A PHP Framework For Web Artisans * * @package Laravel - * @version 3.1.3 + * @version 3.1.4 * @author Taylor Otwell * @link http://laravel.com */ diff --git a/public/index.php b/public/index.php index 9f78eb6e..561d13a3 100644 --- a/public/index.php +++ b/public/index.php @@ -3,7 +3,7 @@ * Laravel - A PHP Framework For Web Artisans * * @package Laravel - * @version 3.1.3 + * @version 3.1.4 * @author Taylor Otwell * @link http://laravel.com */