This is quite the interesting situation:
As per laravel's documentation, the 2nd
parameter of Input::get()
returns a default if none is present.
Unfortunately this line throws an error "data missing" when data-from
is missing, despite specifying a default:
Carbon::createFromFormat('Y/m/d',Input::get('date-from','2015/01/01'))
Full Code:
try
{
$dateFrom = Carbon::createFromFormat('Y/m/d',Input::get('date-from','2015/01/01'));
}
catch(InvalidArgumentException $e)
{
return Response::make($e->getMessage(),500);
}
However, if i do:
Input::has('date-from') ? Carbon::createFromFormat('Y/m/d',Input::get('date-from')) : new Carbon('2015/01/01')
It works perfectly.
The question is simply: why?