src/Entity/PunishCategory.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestampable;
  4. use App\Repository\PunishCategoryRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use JMS\Serializer\Annotation\Groups;
  9. #[ORM\HasLifecycleCallbacks]
  10. #[ORM\Entity(repositoryClassPunishCategoryRepository::class)]
  11. class PunishCategory
  12. {
  13.     use Timestampable;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     #[Groups(['getPunish'])]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255)]
  20.     #[Groups(['getPunish'])]
  21.     private ?string $name null;
  22.     #[ORM\OneToMany(mappedBy'category'targetEntityPunish::class)]
  23.     private Collection $punish;
  24.     #[ORM\ManyToOne(inversedBy'punishCategories'cascade: ["persist"])]
  25.     private ?User $author null;
  26.     #[ORM\ManyToOne(inversedBy'punishCategories'cascade: ["persist"])]
  27.     private ?School $school null;
  28.     public function __construct()
  29.     {
  30.         $this->punish = new ArrayCollection();
  31.     }
  32.     public  function __toString(): string
  33.     {
  34.         return  $this->name;
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getName(): ?string
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function setName(string $name): static
  45.     {
  46.         $this->name $name;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Punish>
  51.      */
  52.     public function getPunish(): Collection
  53.     {
  54.         return $this->punish;
  55.     }
  56.     public function addPunish(Punish $punish): static
  57.     {
  58.         if (!$this->punish->contains($punish)) {
  59.             $this->punish->add($punish);
  60.             $punish->setCategory($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removePunish(Punish $punish): static
  65.     {
  66.         if ($this->punish->removeElement($punish)) {
  67.             // set the owning side to null (unless already changed)
  68.             if ($punish->getCategory() === $this) {
  69.                 $punish->setCategory(null);
  70.             }
  71.         }
  72.         return $this;
  73.     }
  74.     public function getAuthor(): ?User
  75.     {
  76.         return $this->author;
  77.     }
  78.     public function setAuthor(?User $author): static
  79.     {
  80.         $this->author $author;
  81.         return $this;
  82.     }
  83.     public function getSchool(): ?School
  84.     {
  85.         return $this->school;
  86.     }
  87.     public function setSchool(?School $school): static
  88.     {
  89.         $this->school $school;
  90.         return $this;
  91.     }
  92. }