diff --git a/README.md b/README.md index ca742d2..b3970ae 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,8 @@ class Post extends Model ], // This is needed if there is a need to join other tables for derived columns. 'joins' => [ - 'authors' => ['authors.id', 'posts.author_id'] + 'authors' => ['authors.id', 'posts.author_id'], // defaults to leftJoin method of eloquent builder + 'another_table' => ['another_table.id', 'authors.another_table_id', 'join'], // can pass leftJoin, rightJoin, join of eloquent builder. ] ]; diff --git a/src/Searchable.php b/src/Searchable.php index fe346d7..4dd2b96 100644 --- a/src/Searchable.php +++ b/src/Searchable.php @@ -136,7 +136,8 @@ public function searchableJoins() protected function applySearchableJoins($query) { foreach ($this->searchableJoins() as $table => $join) { - $query->leftJoin($table, $join[0], '=', $join[1]); + $joinMethod = $join[2] ?? 'leftJoin'; + $query->{$joinMethod}($table, $join[0], '=', $join[1]); } }