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()); } }