|
|
|
@ -8,6 +8,7 @@ use App\Services\AdminTranslationService; |
|
|
|
use App\Services\EventCalendarService; |
|
|
|
use App\Services\OperationLogService; |
|
|
|
use Maatwebsite\Excel\Concerns\ToModel; |
|
|
|
use PhpOffice\PhpSpreadsheet\Shared\Date; |
|
|
|
|
|
|
|
class EventCalendarImport implements ToModel |
|
|
|
{ |
|
|
|
@ -60,6 +61,7 @@ class EventCalendarImport implements ToModel |
|
|
|
$this->error[] = imports_error($this->index, 'import5'); |
|
|
|
return ; |
|
|
|
} |
|
|
|
$start_date = $this->excelToDateTime($start_date); |
|
|
|
$start_date_times = strtotime($start_date); |
|
|
|
if (!$start_date_times) { |
|
|
|
$this->error[] = imports_error($this->index, 'import6'); |
|
|
|
@ -78,6 +80,7 @@ class EventCalendarImport implements ToModel |
|
|
|
$this->error[] = imports_error($this->index, 'import9'); |
|
|
|
return ; |
|
|
|
} |
|
|
|
$end_date = $this->excelToDateTime($end_date); |
|
|
|
$end_date_times = strtotime($end_date); |
|
|
|
if (!$end_date_times) { |
|
|
|
$this->error[] = imports_error($this->index, 'import10'); |
|
|
|
@ -150,4 +153,13 @@ class EventCalendarImport implements ToModel |
|
|
|
{ |
|
|
|
return $this->error; |
|
|
|
} |
|
|
|
|
|
|
|
protected function excelToDateTime($date): string |
|
|
|
{ |
|
|
|
if (is_numeric($date)) { |
|
|
|
$dateTime = Date::excelToDateTimeObject($date); |
|
|
|
return $dateTime->format('Y-m-d'); |
|
|
|
} |
|
|
|
return $date; |
|
|
|
} |
|
|
|
} |
|
|
|
|