<?php
namespace App\Entity;
use App\Repository\OperatorRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: OperatorRepository::class)]
class Operator extends User
{
#[ORM\OneToOne(targetEntity: OperatorInfo::class, mappedBy: 'owner', cascade: ['persist', 'remove'])]
private $operatorInfo;
#[ORM\Column(type: 'boolean', nullable: true, options: ['default' => false])]
private $isMobile = false;
#[ORM\OneToMany(targetEntity: CoachInfo::class, mappedBy: 'createdByOperator')]
private Collection $createdCoachInfos;
#[ORM\OneToMany(targetEntity: ClubInfo::class, mappedBy: 'createdByOperator')]
private Collection $createdClubInfos;
#[ORM\OneToMany(targetEntity: Partnership::class, mappedBy: 'operator')]
private $partnerships;
public function __construct()
{
parent::__construct();
$this->createdCoachInfos = new ArrayCollection();
$this->createdClubInfos = new ArrayCollection();
$this->partnerships = new ArrayCollection();
}
public function getOperatorInfo(): ?OperatorInfo
{
return $this->operatorInfo;
}
public function setOperatorInfo(OperatorInfo $operatorInfo): self
{
// set the owning side of the relation if necessary
if ($operatorInfo->getOwner() !== $this) {
$operatorInfo->setOwner($this);
}
$this->operatorInfo = $operatorInfo;
return $this;
}
public function getIsMobile(): ?bool
{
return $this->isMobile;
}
public function setIsMobile(?bool $isMobile): self
{
$this->isMobile = $isMobile;
return $this;
}
public function getCreatedCoachInfos(): Collection
{
return $this->createdCoachInfos;
}
public function addCreatedCoachInfo(CoachInfo $coachInfo): self
{
if (!$this->createdCoachInfos->contains($coachInfo)) {
$this->createdCoachInfos[] = $coachInfo;
$coachInfo->setCreatedByOperator($this);
}
return $this;
}
public function removeCreatedCoachInfo(CoachInfo $coachInfo): self
{
if ($this->createdCoachInfos->removeElement($coachInfo)) {
if ($coachInfo->getCreatedByOperator() === $this) {
$coachInfo->setCreatedByOperator(null);
}
}
return $this;
}
public function getCreatedClubInfos(): Collection
{
return $this->createdClubInfos;
}
public function addCreatedClubInfo(ClubInfo $clubInfo): self
{
if (!$this->createdClubInfos->contains($clubInfo)) {
$this->createdClubInfos[] = $clubInfo;
$clubInfo->setCreatedByOperator($this);
}
return $this;
}
public function removeCreatedClubInfo(ClubInfo $clubInfo): self
{
if ($this->createdClubInfos->removeElement($clubInfo)) {
if ($clubInfo->getCreatedByOperator() === $this) {
$clubInfo->setCreatedByOperator(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->setOperator($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->getOperator() === $this) {
$partnership->setOperator(null);
}
}
return $this;
}
}