Skip to content

Commit

Permalink
fix: make direction an optional parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
esbenp committed Feb 23, 2016
1 parent e66677e commit 0215a89
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/LaravelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ protected function parseData($data, array $options, $key = null)
return $architect->parseData($data, $options['modes'], $key);
}

protected function parseSort(array $sort) {
return array_map(function($sort) {
if (!isset($sort['direction'])) {
$sort['direction'] = 'asc';
}

return $sort;
}, $sort);
}

/**
* Parse include strings into resource and modes
* @param array $includes
Expand Down Expand Up @@ -118,7 +128,7 @@ protected function parseResourceOptions()
], $this->defaults);

$includes = $this->parseIncludes($request->get('includes', $this->defaults['includes']));
$sort = $request->get('sort', $this->defaults['sort']);
$sort = $this->parseSort($request->get('sort', $this->defaults['sort']));
$limit = $request->get('limit', $this->defaults['limit']);
$page = $request->get('page', $this->defaults['page']);
$filter_groups = $this->parseFilterGroups($request->get('filter_groups', $this->defaults['filter_groups']));
Expand Down

0 comments on commit 0215a89

Please sign in to comment.