Created
March 18, 2024 16:00
-
-
Save tarlepp/4cea037662e52042d41a8f8ef466ef37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types = 1); | |
namespace App\Entity\Traits; | |
use DateTimeImmutable; | |
use Doctrine\DBAL\Types\Types; | |
use Doctrine\ORM\Mapping as ORM; | |
use Gedmo\Mapping\Annotation as Gedmo; | |
trait Timestampable | |
{ | |
#[ORM\Column( | |
name: 'created_at', | |
type: Types::DATETIME_IMMUTABLE, | |
nullable: true, | |
)] | |
#[Gedmo\Timestampable( | |
on: 'create', | |
)] | |
protected ?DateTimeImmutable $createdAt = null; | |
#[ORM\Column( | |
name: 'updated_at', | |
type: Types::DATETIME_IMMUTABLE, | |
nullable: true, | |
)] | |
#[Gedmo\Timestampable( | |
on: 'update', | |
)] | |
protected ?DateTimeImmutable $updatedAt = null; | |
public function setCreatedAt(DateTimeImmutable $createdAt): self | |
{ | |
$this->createdAt = $createdAt; | |
return $this; | |
} | |
public function getCreatedAt(): ?DateTimeImmutable | |
{ | |
return $this->createdAt; | |
} | |
public function setUpdatedAt(DateTimeImmutable $updatedAt): self | |
{ | |
$this->updatedAt = $updatedAt; | |
return $this; | |
} | |
public function getUpdatedAt(): ?DateTimeImmutable | |
{ | |
return $this->updatedAt; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment