Skip to content

Commit

Permalink
make PowerJoins trait check compatible with both PowerJoins version 2…
Browse files Browse the repository at this point in the history
… & 3
  • Loading branch information
jamesj2 committed Jul 11, 2023
1 parent 165badd commit b027f6c
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/SpladeQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,12 @@ private function applySorting(Column $column)
return $this->builder->orderBy($column->key, $column->sorted);
}

if (!trait_exists(PowerJoins::class)) {
if (!in_array(\Kirschbaum\PowerJoins\PowerJoins::class, class_uses_recursive($this->builder->getModel()))) {
throw new PowerJoinsException(
"To order the query using a column from a relationship, please install the 'kirschbaum-development/eloquent-power-joins' package."
);
}

if (!method_exists($this->builder->getModel(), 'scopeOrderByLeftPowerJoins')) {
throw new PowerJoinsException(
"To order the query using a column from a relationship, make sure the Model uses the 'PowerJoins' trait."
);
}

// Apply the sorting using the PowerJoins package.
return $this->builder->orderByLeftPowerJoins($column->key, $column->sorted);
}
Expand Down

0 comments on commit b027f6c

Please sign in to comment.