feat: due resolution and cascade math

Also: StoresUtc trait normalizes datetime casts to UTC (controller ruling).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
nikita.hohlov
2026-09-04 06:19:00 -03:00
parent 774e0bce1a
commit e48e48aa4a
9 changed files with 297 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Models\Concerns;
use Carbon\CarbonImmutable;
use DateTimeInterface;
/**
* Eloquent форматирует datetime без смещения, поэтому Carbon в чужом поясе
* записался бы как «те же цифры в UTC». Приводим к UTC при присвоении.
*/
trait StoresUtc
{
public function setAttribute($key, $value)
{
if ($value instanceof DateTimeInterface
&& in_array($this->getCasts()[$key] ?? null, ['datetime', 'immutable_datetime'], true)) {
$value = CarbonImmutable::instance($value)->utc();
}
return parent::setAttribute($key, $value);
}
}