src/Entity/UserSegmentation.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserSegmentationRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * Rattachement d'un utilisateur à une valeur de segmentation (une valeur max par axe).
  10.  * Source de vérité des affectations : user.segmentation_id n'est plus qu'un miroir legacy,
  11.  * entretenu par User::setSegmentation() / User::assignSegmentationValue().
  12.  *
  13.  * @ORM\Entity(repositoryClass=UserSegmentationRepository::class)
  14.  * @ORM\Table(name="user_segmentation", uniqueConstraints={
  15.  *      @ORM\UniqueConstraint(name="UNIQ_8B0EDEF7A76ED3953C1509F7", columns={"user_id", "segmentation_id"})
  16.  * })
  17.  * @UniqueEntity(fields={"user", "segmentation"})
  18.  */
  19. class UserSegmentation
  20. {
  21.     /**
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue
  24.      * @ORM\Column(type="integer")
  25.      * @Groups({"user_segmentation:read"})
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="userSegmentations")
  30.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  31.      */
  32.     private $user;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=Segmentation::class)
  35.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  36.      * @Groups({"user_segmentation:read"})
  37.      */
  38.     private $segmentation;
  39.     /**
  40.      * @ORM\Column(type="datetime")
  41.      * @Gedmo\Timestampable(on="create")
  42.      */
  43.     private $createdAt;
  44.     /**
  45.      * @ORM\Column(type="datetime")
  46.      * @Gedmo\Timestampable(on="update")
  47.      */
  48.     private $updatedAt;
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getUser(): ?User
  54.     {
  55.         return $this->user;
  56.     }
  57.     public function setUser(?User $user): self
  58.     {
  59.         $this->user = $user;
  60.         return $this;
  61.     }
  62.     public function getSegmentation(): ?Segmentation
  63.     {
  64.         return $this->segmentation;
  65.     }
  66.     public function setSegmentation(?Segmentation $segmentation): self
  67.     {
  68.         $this->segmentation = $segmentation;
  69.         return $this;
  70.     }
  71.     public function getCreatedAt(): ?\DateTimeInterface
  72.     {
  73.         return $this->createdAt;
  74.     }
  75.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  76.     {
  77.         $this->createdAt = $createdAt;
  78.         return $this;
  79.     }
  80.     public function getUpdatedAt(): ?\DateTimeInterface
  81.     {
  82.         return $this->updatedAt;
  83.     }
  84.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  85.     {
  86.         $this->updatedAt = $updatedAt;
  87.         return $this;
  88.     }
  89. }