From 587a80acbbf6ba5a29e51de7e2155d193605b661 Mon Sep 17 00:00:00 2001 From: Kelly Banman Date: Mon, 2 Apr 2012 14:59:44 -0700 Subject: [PATCH 1/2] Timestamps are optional in many-to-many pivot table Signed-off-by: Kelly Banman --- .../eloquent/relationships/has_many_and_belongs_to.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 2f5e4a89..a3ea36b5 100644 --- a/laravel/database/eloquent/relationships/has_many_and_belongs_to.php +++ b/laravel/database/eloquent/relationships/has_many_and_belongs_to.php @@ -25,7 +25,7 @@ class Has_Many_And_Belongs_To extends Relationship { * * @var array */ - protected $with = array('id', 'created_at', 'updated_at'); + protected $with = array(); /** * Create a new many to many relationship instance. @@ -43,6 +43,11 @@ public function __construct($model, $associated, $table, $foreign, $other) $this->joining = $table ?: $this->joining($model, $associated); + if (Pivot::$timestamps) + { + $this->with = array('id', 'created_at', 'updated_at'); + } + parent::__construct($model, $associated, $foreign); } From 63e6d143fba9a47da632857d73998c5e93f3d496 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 4 Apr 2012 10:36:48 -0500 Subject: [PATCH 2/2] updated change log. --- laravel/documentation/changes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/laravel/documentation/changes.md b/laravel/documentation/changes.md index 78298186..7e6b8574 100644 --- a/laravel/documentation/changes.md +++ b/laravel/documentation/changes.md @@ -29,6 +29,7 @@ ## Laravel 3.2 - Improved View performance by only loading contents from file once. - Fix handling of URLs beginning with has in URL::to. - Fix the resolution of unset Eloquent attributes. +- Allows pivot table timestamps to be disabled. ## Upgrading From 3.1