Skip to content

Commit

Permalink
Merge pull request #102 from zenn1989/master
Browse files Browse the repository at this point in the history
Phpdoc, fix using eloquent table prefix
  • Loading branch information
nicolaslopezj committed Jan 27, 2016
2 parents 054f14f + b7673e2 commit 347f76d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/SearchableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
/**
* Trait SearchableTrait
* @package Nicolaslopezj\Searchable
* @property array $searchable
* @property string $table
* @property string $primaryKey
* @method string getTable()
*/
trait SearchableTrait
{
Expand Down Expand Up @@ -314,10 +318,11 @@ protected function addBindingsToQuery(Builder $query, array $bindings) {
* @param \Illuminate\Database\Eloquent\Builder $original
*/
protected function mergeQueries(Builder $clone, Builder $original) {
if($this->getDatabaseDriver() == 'pgsql'){
$original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as {$this->getTable()}"));
}else{
$original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as `{$this->getTable()}`"));
$tableName = DB::connection($this->connection)->getTablePrefix() . $this->getTable();
if ($this->getDatabaseDriver() == 'pgsql') {
$original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as {$tableName}"));
} else {
$original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as `{$tableName}`"));
}
$original->mergeBindings($clone->getQuery());
}
Expand Down

0 comments on commit 347f76d

Please sign in to comment.