delboy1978uk /
bone-doctrine
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Bone\BoneDoctrine\Traits; |
||
| 6 | |||
| 7 | use DateTimeImmutable; |
||
| 8 | use DateTimeInterface; |
||
| 9 | use DateTimeZone; |
||
| 10 | use Doctrine\ORM\Mapping as ORM; |
||
| 11 | |||
| 12 | #[ORM\HasLifecycleCallbacks] |
||
| 13 | trait HasDeletedAtDate |
||
| 14 | { |
||
| 15 | #[ORM\Column(type: 'datetime_immutable', nullable:true)] |
||
| 16 | private ?DateTimeImmutable $deletedAt = null; |
||
| 17 | |||
| 18 | 1 | public function getDeletedAt(): DateTimeInterface |
|
| 19 | { |
||
| 20 | 1 | return $this->deletedAt; |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 21 | } |
||
| 22 | |||
| 23 | 1 | #[ORM\PreUpdate] |
|
| 24 | public function setDeletedAt(): void |
||
| 25 | { |
||
| 26 | 1 | $this->deletedAt = new DateTimeImmutable('now', new DateTimeZone('UTC')); |
|
| 27 | } |
||
| 28 | } |
||
| 29 |