<?php
namespace App\Entity;
use App\Repository\SeasonRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Annotation\SerializedName;
use App\Annotation\DashboardAnnotation as Dashboard;
use App\Annotation\FormBuildAnnotation as FormBuild;
/**
* @ORM\Entity(repositoryClass=SeasonRepository::class)
* @Dashboard(generation=false, name="Сезон")
*/
class Season
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"collection", "selection/data", "selection/id"})
* @Dashboard(label="Номер", only=true)
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Groups({"collection", "selection/data", "selection/id"})
* @Dashboard(label="Название сезона")
* @FormBuild(component="input")
*/
private $title;
/**
* @ORM\Column(type="boolean")
*/
private $public = true;
/**
* @ORM\OneToMany(targetEntity=Product::class, mappedBy="season", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $products;
public function __construct()
{
$this->productArticles = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function isPublic(): ?bool
{
return $this->public;
}
public function setPublic(bool $public): self
{
$this->public = $public;
return $this;
}
/**
* @return Collection<int, ProductArticle>
*/
public function getProductArticles(): Collection
{
return $this->productArticles;
}
public function addProductArticle(ProductArticle $productArticle): self
{
if (!$this->productArticles->contains($productArticle)) {
$this->productArticles[] = $productArticle;
$productArticle->setSeason($this);
}
return $this;
}
public function removeProductArticle(ProductArticle $productArticle): self
{
if ($this->productArticles->removeElement($productArticle)) {
// set the owning side to null (unless already changed)
if ($productArticle->getSeason() === $this) {
$productArticle->setSeason(null);
}
}
return $this;
}
}