We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 672d152 commit 71aff96Copy full SHA for 71aff96
src/LaravelSubQuery.php
@@ -62,12 +62,14 @@ public function withAvg($relations)
62
public function orderByRelation($relations, $orderType = 'desc', $type = 'max')
63
{
64
if (is_array($relations)) {
65
- $orderType = $relations[0];
66
- $type = $relations[1];
+ $orderType = isset($relations[0]) ? $relations[0] : $orderType;
+ $type = isset($relations[1]) ? $relations[1] : $type;
67
unset($relations[0], $relations[1]);
68
}
69
- if (! strpos($relations, ':')) {
70
- return $this->orderBy($relations, $orderType);
+
+ $column = is_array($relations) ? array_key_first($relations) : $relations;
71
+ if (! strpos($column, ':')) {
72
+ return $this->orderBy($column, $orderType);
73
74
75
return $this->withSubQuery($relations, $type, $orderType);
0 commit comments