Expand API.

This commit is contained in:
James Cole
2018-02-13 18:24:06 +01:00
parent 30f821af3e
commit 370e9b25d1
12 changed files with 405 additions and 46 deletions

View File

@@ -73,27 +73,20 @@ class Controller extends BaseController
}
$bag->set('page', $page);
$start = request()->get('start');
$startDate = null;
if (!is_null($start)) {
try {
$startDate = new Carbon($start);
} catch (InvalidDateException $e) {
// don't care
// some date fields:
$dates = ['start','end','date'];
foreach($dates as $field) {
$date = request()->get($field);
$obj = null;
if (!is_null($date)) {
try {
$obj= new Carbon($date);
} catch (InvalidDateException $e) {
// don't care
}
}
$bag->set($field, $obj);
}
$bag->set('start', $startDate);
$end = request()->get('end');
$endDate = null;
if (!is_null($end)) {
try {
$endDate = new Carbon($end);
} catch (InvalidDateException $e) {
// don't care
}
}
$bag->set('end', $endDate);
$type = request()->get('type') ?? 'all';
$bag->set('type', $type);