Initial commit

This commit is contained in:
lewis committed 2024-08-30 13:28:30 +01:00
commit e6ad944f79
22 files changed
+6566

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace Lewisdale\App\Models\Traits;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
trait AutoUpdate
{
#[ORM\Column(type: 'datetime')]
protected DateTime $createdAt;
#[ORM\Column(type: 'datetime')]
protected DateTime $updatedAt;
#[ORM\PrePersist]
public function onPrePersist(): void {
$this->createdAt = new DateTime('now');
$this->updatedAt = new DateTime('now');
}
#[ORM\PreUpdate]
public function onPreUpdate(): void {
$this->updatedAt = new DateTime('now');
}
}