mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Doctrine\Model;
|
|
|
|
use Chill\MainBundle\Entity\User;
|
|
use DateTime;
|
|
use DateTimeImmutable;
|
|
use DateTimeInterface;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
|
|
trait TrackUpdateTrait
|
|
{
|
|
/**
|
|
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL})
|
|
* @Serializer\Groups({"read"})
|
|
*/
|
|
private ?DateTimeImmutable $updatedAt = null;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=User::class)
|
|
* @ORM\JoinColumn(nullable=true)
|
|
* @Serializer\Groups({"read"})
|
|
*/
|
|
private ?User $updatedBy = null;
|
|
|
|
public function getUpdatedAt(): ?DateTimeInterface
|
|
{
|
|
return $this->updatedAt;
|
|
}
|
|
|
|
public function getUpdatedBy(): ?User
|
|
{
|
|
return $this->updatedBy;
|
|
}
|
|
|
|
public function setUpdatedAt(DateTimeInterface $datetime): self
|
|
{
|
|
$this->updatedAt = $datetime instanceof DateTime ? DateTimeImmutable::createFromMutable($datetime) : $datetime;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setUpdatedBy(User $user): self
|
|
{
|
|
$this->updatedBy = $user;
|
|
|
|
return $this;
|
|
}
|
|
}
|