Feat: Make some entities soft-deletable

This commit is contained in:
Björn Fromme
2023-10-20 17:17:21 +02:00
parent 168a69c103
commit d7bbb4bb29
27 changed files with 213 additions and 63 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Entity\Traits;
use Doctrine\ORM\Mapping as ORM;
trait SoftDeletableEntity
{
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $deletedAt = null;
public function getDeletedAt(): \DateTimeImmutable
{
return $this->deletedAt;
}
public function setDeletedAt(\DateTimeImmutable $deletedAt): static
{
$this->deletedAt = $deletedAt;
return $this;
}
public function setDeleted(): static
{
$this->setDeletedAt(new \DateTimeImmutable());
return $this;
}
public function isDeleted(): bool
{
return null !== $this->getDeletedAt();
}
}