src/Entity/Univers.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UniversRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. use JMS\Serializer\Annotation\Expose;
  9. use JMS\Serializer\Annotation\Groups;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. /**
  12.  * @ORM\Entity(repositoryClass=UniversRepository::class)
  13.  *
  14.  * @UniqueEntity("slug")
  15.  * @Serializer\ExclusionPolicy("ALL")
  16.  */
  17. class Univers
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      *
  24.      * @Expose
  25.      * @Groups({"univers", "user",})
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      *
  31.      * @Expose
  32.      * @Groups({"univers", "user"})
  33.      */
  34.     private $slug;
  35.     /**
  36.      * @ORM\Column(type="text", nullable=true)
  37.      *
  38.      * @Expose
  39.      * @Groups({"univers", "user"})
  40.      */
  41.     private $description;
  42.     /**
  43.      * @ORM\Column(type="integer")
  44.      *
  45.      * @Expose
  46.      * @Groups({"univers"})
  47.      */
  48.     private $rootCatId;
  49.     /**
  50.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="universes")
  51.      *
  52.      * @Expose
  53.      * @Groups({"univers", "user"})
  54.      */
  55.     private $users;
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      *
  59.      * @Expose
  60.      * @Groups({"univers"})
  61.      */
  62.     private $slugCatalogue;
  63.     public function __construct()
  64.     {
  65.         $this->users = new ArrayCollection();
  66.     }
  67.     public function getId(): ?int
  68.     {
  69.         return $this->id;
  70.     }
  71.     public function getSlug(): ?string
  72.     {
  73.         return $this->slug;
  74.     }
  75.     public function setSlug(string $slug): self
  76.     {
  77.         $this->slug $slug;
  78.         return $this;
  79.     }
  80.     public function getDescription(): ?string
  81.     {
  82.         return $this->description;
  83.     }
  84.     public function setDescription(?string $description): self
  85.     {
  86.         $this->description $description;
  87.         return $this;
  88.     }
  89.     public function getRootCatId(): ?int
  90.     {
  91.         return $this->rootCatId;
  92.     }
  93.     public function setRootCatId(int $rootCatId): self
  94.     {
  95.         $this->rootCatId $rootCatId;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, User>
  100.      */
  101.     public function getUsers(): Collection
  102.     {
  103.         return $this->users;
  104.     }
  105.     public function addUser(User $user): self
  106.     {
  107.         if (!$this->users->contains($user)) {
  108.             $this->users[] = $user;
  109.         }
  110.         return $this;
  111.     }
  112.     public function removeUser(User $user): self
  113.     {
  114.         $this->users->removeElement($user);
  115.         return $this;
  116.     }
  117.     public function getSlugCatalogue(): ?string
  118.     {
  119.         return $this->slugCatalogue;
  120.     }
  121.     public function setSlugCatalogue(?string $slugCatalogue): self
  122.     {
  123.         $this->slugCatalogue $slugCatalogue;
  124.         return $this;
  125.     }
  126. }