fixed import where it did not reactivate contract that was archived

This commit is contained in:
Simon Pocrnjič
2025-10-30 19:49:31 +01:00
parent cb7851f91c
commit bdde610178
2 changed files with 39 additions and 6 deletions
+33
View File
@@ -3,6 +3,7 @@
namespace App\Models;
use App\Traits\Uuid;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -43,6 +44,38 @@ protected function casts(): array
];
}
/**
* Normalize start_date inputs to Y-m-d (or null) on assignment.
*/
protected function startDate(): Attribute
{
return Attribute::make(
set: function ($value) {
if (is_null($value)) {
return null;
}
$str = is_string($value) ? $value : (string) $value;
return \App\Services\DateNormalizer::toDate($str);
}
);
}
/**
* Normalize end_date inputs to Y-m-d (or null) on assignment.
*/
protected function endDate(): Attribute
{
return Attribute::make(
set: function ($value) {
if (is_null($value)) {
return null;
}
$str = is_string($value) ? $value : (string) $value;
return \App\Services\DateNormalizer::toDate($str);
}
);
}
public function type(): BelongsTo
{
return $this->belongsTo(\App\Models\ContractType::class, 'type_id');