Skip to content

Commit

Permalink
Merge pull request #10 from langleyfoxall/feature/check-order-by-dire…
Browse files Browse the repository at this point in the history
…ction

Move order by direction check to more appropriate location
  • Loading branch information
Jordan Hall authored Apr 7, 2020
2 parents 5a060f7 + f371798 commit b97f9fa
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 b97f9fa

Please sign in to comment.