fixed #485
This commit is contained in:
parent
7eba729e21
commit
7d643ca58e
@ -43,20 +43,8 @@ class Import
|
|||||||
|
|
||||||
// Loop through all rows
|
// Loop through all rows
|
||||||
$sheet->each(function ($row, $index) use ($sheet, &$success, $model, $request) {
|
$sheet->each(function ($row, $index) use ($sheet, &$success, $model, $request) {
|
||||||
$data = $row->toArray();
|
$data = static::fixRow($row->toArray());
|
||||||
|
|
||||||
// Fix the date fields
|
|
||||||
$date_fields = ['paid_at', 'due_at', 'billed_at', 'invoiced_at'];
|
|
||||||
foreach ($date_fields as $date_field) {
|
|
||||||
if (empty($data[$date_field])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_date = Date::parse($data[$date_field])->format('Y-m-d') . ' ' . Date::now()->format('H:i:s');
|
|
||||||
|
|
||||||
$data[$date_field] = $new_date;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the line values so that request class could validate
|
// Set the line values so that request class could validate
|
||||||
request()->merge($data);
|
request()->merge($data);
|
||||||
|
|
||||||
@ -104,4 +92,26 @@ class Import
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function fixRow($data)
|
||||||
|
{
|
||||||
|
// Fix the date fields
|
||||||
|
$date_fields = ['paid_at', 'due_at', 'billed_at', 'invoiced_at'];
|
||||||
|
foreach ($date_fields as $date_field) {
|
||||||
|
if (empty($data[$date_field])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_date = Date::parse($data[$date_field])->format('Y-m-d') . ' ' . Date::now()->format('H:i:s');
|
||||||
|
|
||||||
|
$data[$date_field] = $new_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make enabled field integer
|
||||||
|
if (isset($data['enabled'])) {
|
||||||
|
$data['enabled'] = (int) $data['enabled'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user