birthday normalise date

This commit is contained in:
Simon Pocrnjič 2026-01-14 22:09:04 +01:00
parent 8fdc0d6359
commit ca8754cd94

View File

@ -24,6 +24,7 @@
use App\Models\Person\PersonPhone; use App\Models\Person\PersonPhone;
use App\Models\Person\PersonType; use App\Models\Person\PersonType;
use App\Models\Person\PhoneType; use App\Models\Person\PhoneType;
use Exception;
use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
@ -2987,6 +2988,16 @@ private function findOrCreatePersonId(array $p): ?int
$data['full_name'] = trim($fn.' '.$ln); $data['full_name'] = trim($fn.' '.$ln);
} }
} }
// normalise birthday date
if (!empty($data['birthday'])) {
try {
$data['birthday'] = date('Y-m-d', strtotime($data['birthday']));
} catch (Exception $e) {
Log::warning('ImportProcessor::findOrCreatePersonId ' . $e->getMessage());
}
}
// ensure required group/type ids // ensure required group/type ids
$data['group_id'] = $data['group_id'] ?? $this->getDefaultPersonGroupId(); $data['group_id'] = $data['group_id'] ?? $this->getDefaultPersonGroupId();
$data['type_id'] = $data['type_id'] ?? $this->getDefaultPersonTypeId(); $data['type_id'] = $data['type_id'] ?? $this->getDefaultPersonTypeId();