From 172ebcb00d60400060b7fa5028a4558e0233b193 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 9 Nov 2012 02:15:28 +0100 Subject: [PATCH] Fix Pivot table losing its connection. This hopefully fixes #1198 and while it doesn't solve the underlying problem mentioned in #1429, it does the tackle the resulting mess. :) --- laravel/database/eloquent/pivot.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/laravel/database/eloquent/pivot.php b/laravel/database/eloquent/pivot.php index a90d7e7d..ba2279e0 100644 --- a/laravel/database/eloquent/pivot.php +++ b/laravel/database/eloquent/pivot.php @@ -7,7 +7,14 @@ class Pivot extends Model { * * @var string */ - public $pivot_table; + protected $pivot_table; + + /** + * The database connection used for this model. + * + * @var Laravel\Database\Connection + */ + protected $pivot_connection; /** * Indicates if the model has update and creation timestamps. @@ -26,7 +33,7 @@ class Pivot extends Model { public function __construct($table, $connection = null) { $this->pivot_table = $table; - static::$connection = $connection; + $this->pivot_connection = $connection; parent::__construct(array(), true); } @@ -41,4 +48,14 @@ public function table() return $this->pivot_table; } + /** + * Get the connection used by the pivot table. + * + * @return string + */ + public function connection() + { + return $this->pivot_connection; + } + } \ No newline at end of file