update for version 1.0.2
This commit is contained in:
@@ -92,7 +92,7 @@ trait SearchableTrait
|
||||
* @return array
|
||||
*/
|
||||
protected function getDatabaseDriver() {
|
||||
$key = Config::get('database.default');
|
||||
$key = $this->connection ?: Config::get('database.default');
|
||||
return Config::get('database.connections.' . $key . '.driver');
|
||||
}
|
||||
|
||||
@@ -137,9 +137,13 @@ trait SearchableTrait
|
||||
*/
|
||||
protected function makeJoins(Builder $query)
|
||||
{
|
||||
foreach ($this->getJoins() as $table => $keys)
|
||||
{
|
||||
$query->leftJoin($table, $keys[0], '=', $keys[1]);
|
||||
foreach ($this->getJoins() as $table => $keys) {
|
||||
$query->leftJoin($table, function ($join) use ($keys) {
|
||||
$join->on($keys[0], '=', $keys[1]);
|
||||
if (array_key_exists(2, $keys) && array_key_exists(3, $keys)) {
|
||||
$join->where($keys[2], '=', $keys[3]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +291,7 @@ trait SearchableTrait
|
||||
* @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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user