<?phpnamespace App\Entity;use App\Repository\ReductionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=ReductionRepository::class) */class Reduction{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $titre; /** * @ORM\Column(type="date", nullable=true) */ private $dateValidity; /** * @ORM\ManyToOne(targetEntity=Enterprise::class, inversedBy="reductions") */ private $enterprise; /** * @ORM\OneToMany(targetEntity=ReductionItem::class, mappedBy="reduction",cascade={"persist"}) */ private $reductionItems; /** * @ORM\OneToMany(targetEntity=ReductionRequest::class, mappedBy="reduction",cascade={"persist"}) */ private $reductionRequests; public function __construct() { $this->reductionItems = new ArrayCollection(); $this->reductionRequests = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getTitre(): ?string { return $this->titre; } public function setTitre(string $titre): self { $this->titre = $titre; return $this; } public function getDateValidity(): ?\DateTimeInterface { return $this->dateValidity; } public function setDateValidity(?\DateTimeInterface $dateValidity): self { $this->dateValidity = $dateValidity; return $this; } public function getEnterprise(): ?Enterprise { return $this->enterprise; } public function setEnterprise(?Enterprise $enterprise): self { $this->enterprise = $enterprise; return $this; } /** * @return Collection|ReductionItem[] */ public function getReductionItems(): Collection { return $this->reductionItems; } public function addReductionItem(ReductionItem $reductionItem): self { if (!$this->reductionItems->contains($reductionItem)) { $this->reductionItems[] = $reductionItem; $reductionItem->setReduction($this); } return $this; } public function removeReductionItem(ReductionItem $reductionItem): self { if ($this->reductionItems->removeElement($reductionItem)) { // set the owning side to null (unless already changed) if ($reductionItem->getReduction() === $this) { $reductionItem->setReduction(null); } } return $this; } /** * @return Collection|ReductionRequest[] */ public function getReductionRequests(): Collection { return $this->reductionRequests; } public function addReductionRequest(ReductionRequest $reductionRequest): self { if (!$this->reductionRequests->contains($reductionRequest)) { $this->reductionRequests[] = $reductionRequest; $reductionRequest->setReduction($this); } return $this; } public function removeReductionRequest(ReductionRequest $reductionRequest): self { if ($this->reductionRequests->removeElement($reductionRequest)) { // set the owning side to null (unless already changed) if ($reductionRequest->getReduction() === $this) { $reductionRequest->setReduction(null); } } return $this; } public function isValid():bool { $now = new \DateTime(); if($now > $this->dateValidity) return false; return true; }}