<?php
namespace App\Entity;
use App\Entity\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\CoachRepository;
#[ORM\Entity(repositoryClass: CoachRepository::class)]
class Coach extends User
{
#[ORM\OneToOne(targetEntity: CoachInfo::class, mappedBy: 'owner', cascade: ['persist', 'remove'])]
private $coachInfo;
#[ORM\Column(type: 'boolean', nullable: true, options: ['default' => true])]
private $isMobile = true;
#[ORM\OneToMany(targetEntity: ClubInfo::class, mappedBy: 'createdByCoach')]
private Collection $createdClubInfos;
#[ORM\OneToMany(targetEntity: Partnership::class, mappedBy: 'coach')]
private $partnerships;
public function __construct()
{
$this->createdClubInfos = new ArrayCollection();
$this->partnerships = new ArrayCollection();
}
public function getCoachInfo(): ?CoachInfo
{
return $this->coachInfo;
}
public function setCoachInfo(?CoachInfo $coachInfo): self
{
// unset the owning side of the relation if necessary
if ($coachInfo === null && $this->coachInfo !== null) {
$this->coachInfo->setOwner(null);
}
// set the owning side of the relation if necessary
if ($coachInfo !== null && $coachInfo->getOwner() !== $this) {
$coachInfo->setOwner($this);
}
$this->coachInfo = $coachInfo;
return $this;
}
public function getIsMobile(): ?bool
{
return $this->isMobile;
}
public function setIsMobile(bool $isMobile): self
{
$this->isMobile = $isMobile;
return $this;
}
public function getCreatedClubInfos(): Collection
{
return $this->createdClubInfos;
}
public function addCreatedClubInfo(ClubInfo $clubInfo): self
{
if (!$this->createdClubInfos->contains($clubInfo)) {
$this->createdClubInfos[] = $clubInfo;
$clubInfo->setCreatedByCoach($this);
}
return $this;
}
public function removeCreatedClubInfo(ClubInfo $clubInfo): self
{
if ($this->createdClubInfos->removeElement($clubInfo)) {
if ($clubInfo->getCreatedByCoach() === $this) {
$clubInfo->setCreatedByCoach(null);
}
}
return $this;
}
/**
* @return Collection|Partnership[]
*/
public function getPartnerships(): Collection
{
return $this->partnerships;
}
public function addPartnership(Partnership $partnership): self
{
if (!$this->partnerships->contains($partnership)) {
$this->partnerships[] = $partnership;
$partnership->setCoach($this);
}
return $this;
}
public function removePartnership(Partnership $partnership): self
{
if ($this->partnerships->removeElement($partnership)) {
// set the owning side to null (unless already changed)
if ($partnership->getCoach() === $this) {
$partnership->setCoach(null);
}
}
return $this;
}
}