diff --git a/src/SpladeQueryBuilder.php b/src/SpladeQueryBuilder.php index e9330441..a04bfe5b 100644 --- a/src/SpladeQueryBuilder.php +++ b/src/SpladeQueryBuilder.php @@ -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); }