Feat: Make some entities soft-deletable
This commit is contained in:
1 parent
168a69c103
commit
d7bbb4bb29
27 files changed
+213
-63
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user