src/Entity/Season.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SeasonRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation as Serializer;
  8. use Symfony\Component\Serializer\Annotation\SerializedName;
  9. use App\Annotation\DashboardAnnotation as Dashboard;
  10. use App\Annotation\FormBuildAnnotation as FormBuild;
  11. /**
  12.  * @ORM\Entity(repositoryClass=SeasonRepository::class)
  13.  * @Dashboard(generation=false, name="Сезон")
  14.  */
  15. class Season
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      * @Serializer\Groups({"collection", "selection/data", "selection/id"})
  22.      * @Dashboard(label="Номер", only=true)
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      * @Serializer\Groups({"collection", "selection/data", "selection/id"}) 
  28.      * @Dashboard(label="Название сезона")
  29.      * @FormBuild(component="input")
  30.      */
  31.     private $title;
  32.     /**
  33.      * @ORM\Column(type="boolean")
  34.      */
  35.     private $public true;
  36.     /**
  37.      * @ORM\OneToMany(targetEntity=Product::class, mappedBy="season", cascade={"persist", "remove"}, orphanRemoval=true)
  38.      */
  39.     private $products;
  40.     public function __construct()
  41.     {
  42.         $this->productArticles = new ArrayCollection();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getTitle(): ?string
  49.     {
  50.         return $this->title;
  51.     }
  52.     public function setTitle(string $title): self
  53.     {
  54.         $this->title $title;
  55.         return $this;
  56.     }
  57.     public function isPublic(): ?bool
  58.     {
  59.         return $this->public;
  60.     }
  61.     public function setPublic(bool $public): self
  62.     {
  63.         $this->public $public;
  64.         return $this;
  65.     }
  66.     /**
  67.      * @return Collection<int, ProductArticle>
  68.      */
  69.     public function getProductArticles(): Collection
  70.     {
  71.         return $this->productArticles;
  72.     }
  73.     public function addProductArticle(ProductArticle $productArticle): self
  74.     {
  75.         if (!$this->productArticles->contains($productArticle)) {
  76.             $this->productArticles[] = $productArticle;
  77.             $productArticle->setSeason($this);
  78.         }
  79.         return $this;
  80.     }
  81.     public function removeProductArticle(ProductArticle $productArticle): self
  82.     {
  83.         if ($this->productArticles->removeElement($productArticle)) {
  84.             // set the owning side to null (unless already changed)
  85.             if ($productArticle->getSeason() === $this) {
  86.                 $productArticle->setSeason(null);
  87.             }
  88.         }
  89.         return $this;
  90.     }
  91. }