Skip to content

Commit b97f9fa

Browse files
author
Jordan Hall
authored
Merge pull request #10 from langleyfoxall/feature/check-order-by-direction
Move order by direction check to more appropriate location
2 parents 5a060f7 + f371798 commit b97f9fa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/DataTableResponder.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ private function buildQuery(Request $request)
144144
$orderByField = $request->get('orderByField');
145145
$orderByDirection = $request->get('orderByDirection');
146146

147-
if (!in_array(strtolower($orderByDirection), ['asc', 'desc'])) {
148-
throw new InvalidArgumentException('Order by direction must be either asc or desc.');
149-
}
150-
151147
$query = $this->model->query();
152148

153149
if ($orderByField && $orderByDirection) {
150+
if (!in_array(strtolower($orderByDirection), ['asc', 'desc'])) {
151+
throw new InvalidArgumentException('Order by direction must be either asc or desc.');
152+
}
153+
154154
if (in_array($orderByField, array_keys($this->orderByOverrides))) {
155155
call_user_func_array(
156156
$this->orderByOverrides[$orderByField],

0 commit comments

Comments
 (0)