Created
December 11, 2024 08:04
-
-
Save michitheonlyone/fcd43377d2b13d7da9b6a9cb730e97a2 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; | |
use Doctrine\ORM\Mapping as ORM; | |
use Gedmo\Mapping\Annotation\Versioned; | |
trait AssigneableEntityTrait | |
{ | |
#[ORM\ManyToOne] | |
#[Versioned] | |
private ?Client $assignedClient = null; | |
#[ORM\ManyToOne] | |
#[Versioned] | |
private ?Group $assignedGroup = null; | |
#[ORM\ManyToOne] | |
#[Versioned] | |
private ?User $assignedUser = null; | |
public function getAssignedClient(): ?Client | |
{ | |
return $this->assignedClient; | |
} | |
public function setAssignedClient(Client $assignedClient): self | |
{ | |
$this->assignedClient = $assignedClient; | |
return $this; | |
} | |
public function getAssignedGroup(): ?Group | |
{ | |
return $this->assignedGroup; | |
} | |
public function setAssignedGroup(Group $assignedGroup): self | |
{ | |
$this->assignedGroup = $assignedGroup; | |
return $this; | |
} | |
public function getAssignedUser(): ?User | |
{ | |
return $this->assignedUser; | |
} | |
public function setAssignedUser(User $assignedUser): self | |
{ | |
$this->assignedUser = $assignedUser; | |
return $this; | |
} | |
} |
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; | |
use Doctrine\DBAL\Types\Types; | |
use Doctrine\ORM\Mapping as ORM; | |
use Gedmo\Mapping\Annotation\Blameable; | |
use Gedmo\Mapping\Annotation\Timestampable; | |
// TODO refactor all datetimes to datetimez | |
// #[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: true)] | |
// https://github.com/doctrine/orm/blob/2.14.x/docs/en/cookbook/working-with-datetime.rst | |
trait BlameableEntityTrait | |
{ | |
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)] | |
#[Timestampable(on: 'create')] | |
protected ?\DateTimeImmutable $createdAt = null; | |
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: true)] | |
#[Timestampable(on: 'update')] | |
protected ?\DateTimeImmutable $updatedAt = null; | |
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: true)] | |
protected ?\DateTimeImmutable $deletedAt = null; | |
#[ORM\ManyToOne] | |
#[Blameable(on: 'create')] | |
private ?User $createdByUser = null; | |
#[ORM\ManyToOne] | |
#[Blameable(on: 'update')] | |
private ?User $updatedByUser = null; | |
#[ORM\ManyToOne] | |
private ?User $deletedByUser = null; | |
public function getCreatedAt(): ?\DateTimeImmutable | |
{ | |
return $this->createdAt; | |
} | |
public function setCreatedAt(\DateTimeImmutable $createdAt): static | |
{ | |
$this->createdAt = $createdAt; | |
return $this; | |
} | |
public function getUpdatedAt(): ?\DateTimeImmutable | |
{ | |
return $this->updatedAt; | |
} | |
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): static | |
{ | |
$this->updatedAt = $updatedAt; | |
return $this; | |
} | |
public function getDeletedAt(): ?\DateTimeImmutable | |
{ | |
return $this->deletedAt; | |
} | |
public function setDeletedAt(?\DateTimeImmutable $deletedAt): static | |
{ | |
$this->deletedAt = $deletedAt; | |
return $this; | |
} | |
public function getCreatedByUser(): ?User | |
{ | |
return $this->createdByUser; | |
} | |
public function setCreatedByUser(?User $createdByUser): static | |
{ | |
$this->createdByUser = $createdByUser; | |
return $this; | |
} | |
public function getUpdatedByUser(): ?User | |
{ | |
return $this->updatedByUser; | |
} | |
public function setUpdatedByUser(?User $updatedByUser): static | |
{ | |
$this->updatedByUser = $updatedByUser; | |
return $this; | |
} | |
public function getDeletedByUser(): ?User | |
{ | |
return $this->deletedByUser; | |
} | |
public function setDeletedByUser(?User $deletedByUser): static | |
{ | |
$this->deletedByUser = $deletedByUser; | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment