Skip to content

Commit

Permalink
Merge pull request #84 from wunc/master
Browse files Browse the repository at this point in the history
Add polymorphic capability to joins.
  • Loading branch information
nicolaslopezj committed Oct 20, 2015
2 parents bf47a90 + 20c54de commit 14e70fc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/SearchableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,13 @@ protected function getJoins()
*/
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]);
}
});
}
}

Expand Down

0 comments on commit 14e70fc

Please sign in to comment.