<?phpnamespace App\Entity\Club1895;use App\Entity\Enum\RegistrationStatus;use App\Entity\GlobalSeason;use App\Entity\Season;use App\Entity\Section;use App\Entity\Traits\Identifiable;use App\Repository\Club1895\RegistrationRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: RegistrationRepository::class)]#[ORM\Table(name: 'club1895_registration')]class Registration{ use Identifiable; public const DEFAULT_AMOUNT = 250; #[ORM\ManyToOne(inversedBy: 'registrations')] #[ORM\JoinColumn(nullable: false)] private ?Club1895Profile $profile = null; #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?GlobalSeason $globalSeason = null; #[ORM\ManyToOne] private ?Season $season = null; #[ORM\OneToMany(mappedBy: 'registration', targetEntity: Transaction::class, orphanRemoval: true)] private Collection $transactions; #[ORM\Column(length: 255, enumType: RegistrationStatus::class, options: ['default' => RegistrationStatus::Payment])] private ?RegistrationStatus $status = RegistrationStatus::Payment; #[ORM\ManyToOne] private ?Section $section = null; public function __construct() { $this->transactions = new ArrayCollection(); } public function getProfile(): ?Club1895Profile { return $this->profile; } public function setProfile(?Club1895Profile $profile): self { $this->profile = $profile; return $this; } public function getGlobalSeason(): ?GlobalSeason { return $this->globalSeason; } public function setGlobalSeason(?GlobalSeason $globalSeason): self { $this->globalSeason = $globalSeason; return $this; } public function getSeason(): ?Season { return $this->season; } public function setSeason(?Season $season): self { $this->season = $season; return $this; } /** * @return Collection<int, Transaction> */ public function getTransactions(): Collection { return $this->transactions; } public function addTransaction(Transaction $transaction): self { if (!$this->transactions->contains($transaction)) { $this->transactions->add($transaction); $transaction->setRegistration($this); } return $this; } public function removeTransaction(Transaction $transaction): self { if ($this->transactions->removeElement($transaction)) { // set the owning side to null (unless already changed) if ($transaction->getRegistration() === $this) { $transaction->setRegistration(null); } } return $this; } public function getStatus(): ?RegistrationStatus { return $this->status; } public function setStatus(RegistrationStatus $status): self { $this->status = $status; return $this; } public function getRemainingAmount(): float { $amountPayed = 0; foreach ($this->getTransactions() as $transaction) { $amountPayed += $transaction->getAmountPayed(); } return self::DEFAULT_AMOUNT - $amountPayed; } public function getSection(): ?Section { return $this->section; } public function setSection(?Section $section): self { $this->section = $section; return $this; }}