Set default date
This commit is contained in:
@ -61,7 +61,12 @@ class Precios
|
|||||||
{
|
{
|
||||||
$body = $request->getParsedBody();
|
$body = $request->getParsedBody();
|
||||||
$projectId = $body['project_id'];
|
$projectId = $body['project_id'];
|
||||||
$date = $body['date'];
|
if (array_key_exists('date', $body)) {
|
||||||
|
$date = $body['date'];
|
||||||
|
$date = DateTime::createFromFormat('Y-m-d', $date);
|
||||||
|
} else {
|
||||||
|
$date = new DateTime();
|
||||||
|
}
|
||||||
$file = $request->getUploadedFiles()['file'];
|
$file = $request->getUploadedFiles()['file'];
|
||||||
$output = [
|
$output = [
|
||||||
'input' => $body,
|
'input' => $body,
|
||||||
@ -69,7 +74,6 @@ class Precios
|
|||||||
'precios' => [],
|
'precios' => [],
|
||||||
'status' => false
|
'status' => false
|
||||||
];
|
];
|
||||||
$date = DateTime::createFromFormat('Y-m-d', $date);
|
|
||||||
try {
|
try {
|
||||||
$output['precios'] = $precioService->import($projectId, $date, $file);
|
$output['precios'] = $precioService->import($projectId, $date, $file);
|
||||||
$output['total'] = count($output['precios']);
|
$output['total'] = count($output['precios']);
|
||||||
|
|||||||
Reference in New Issue
Block a user