Skip to content

Commit

Permalink
Move order by direction check to more appropriate location
Browse files Browse the repository at this point in the history
  • Loading branch information
DivineOmega committed Apr 7, 2020
1 parent 991b5c5 commit f371798
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/DataTableResponder.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ private function buildQuery(Request $request)
$orderByField = $request->get('orderByField');
$orderByDirection = $request->get('orderByDirection');

if (!in_array(strtolower($orderByDirection), ['asc', 'desc'])) {
throw new InvalidArgumentException('Order by direction must be either asc or desc.');
}

$query = $this->model->query();

if ($orderByField && $orderByDirection) {
if (!in_array(strtolower($orderByDirection), ['asc', 'desc'])) {
throw new InvalidArgumentException('Order by direction must be either asc or desc.');
}

if (in_array($orderByField, array_keys($this->orderByOverrides))) {
call_user_func_array(
$this->orderByOverrides[$orderByField],
Expand Down

0 comments on commit f371798

Please sign in to comment.