From 5be43861728efe40ddd7fabc3c4564e45df097a4 Mon Sep 17 00:00:00 2001 From: Jarno van Leeuwen Date: Tue, 27 Oct 2015 22:28:41 +0100 Subject: [PATCH] Added support for multiple connections. --- src/SearchableTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SearchableTrait.php b/src/SearchableTrait.php index 7dd37c6..3645f36 100644 --- a/src/SearchableTrait.php +++ b/src/SearchableTrait.php @@ -92,7 +92,7 @@ public function scopeSearchRestricted(Builder $q, $search, $restriction, $thresh * @return array */ protected function getDatabaseDriver() { - $key = Config::get('database.default'); + $key = $this->connection ?: Config::get('database.default'); return Config::get('database.connections.' . $key . '.driver'); } @@ -291,7 +291,7 @@ protected function addBindingsToQuery(Builder $query, array $bindings) { * @param \Illuminate\Database\Eloquent\Builder $original */ protected function mergeQueries(Builder $clone, Builder $original) { - $original->from(DB::raw("({$clone->toSql()}) as `{$this->getTable()}`")); + $original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as `{$this->getTable()}`")); $original->mergeBindings($clone->getQuery()); } }