<?phpnamespace App\Entity;use App\Repository\UserSegmentationRepository;use Doctrine\ORM\Mapping as ORM;use Gedmo\Mapping\Annotation as Gedmo;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Serializer\Annotation\Groups;/** * Rattachement d'un utilisateur à une valeur de segmentation (une valeur max par axe). * Source de vérité des affectations : user.segmentation_id n'est plus qu'un miroir legacy, * entretenu par User::setSegmentation() / User::assignSegmentationValue(). * * @ORM\Entity(repositoryClass=UserSegmentationRepository::class) * @ORM\Table(name="user_segmentation", uniqueConstraints={ * @ORM\UniqueConstraint(name="UNIQ_8B0EDEF7A76ED3953C1509F7", columns={"user_id", "segmentation_id"}) * }) * @UniqueEntity(fields={"user", "segmentation"}) */class UserSegmentation{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") * @Groups({"user_segmentation:read"}) */ private $id; /** * @ORM\ManyToOne(targetEntity=User::class, inversedBy="userSegmentations") * @ORM\JoinColumn(nullable=false, onDelete="CASCADE") */ private $user; /** * @ORM\ManyToOne(targetEntity=Segmentation::class) * @ORM\JoinColumn(nullable=false, onDelete="CASCADE") * @Groups({"user_segmentation:read"}) */ private $segmentation; /** * @ORM\Column(type="datetime") * @Gedmo\Timestampable(on="create") */ private $createdAt; /** * @ORM\Column(type="datetime") * @Gedmo\Timestampable(on="update") */ private $updatedAt; public function getId(): ?int { return $this->id; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } public function getSegmentation(): ?Segmentation { return $this->segmentation; } public function setSegmentation(?Segmentation $segmentation): self { $this->segmentation = $segmentation; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(?\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(?\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; }}