<?php
namespace App\Entity;
use App\Repository\ClubInfoRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ClubInfoRepository::class)]
class ClubInfo
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'boolean', nullable: true)]
private $swimmingpool;
#[ORM\Column(type: 'boolean', nullable: true)]
private $gym;
#[ORM\Column(type: 'boolean', nullable: true)]
private $restaurant;
#[ORM\Column(type: 'boolean', nullable: true)]
private $bar;
#[ORM\Column(type: 'boolean', nullable: true)]
private $seminarRoom;
#[ORM\Column(type: 'boolean', nullable: true)]
private $insurance;
#[ORM\OneToOne(targetEntity: Club::class, inversedBy: 'clubInfo', cascade: ['persist'], fetch: "EAGER")]
private $owner;
#[ORM\OneToMany(targetEntity: CourtInfo::class, mappedBy: 'clubInfo', cascade: ['persist', 'remove'])]
private $courtInfos;
#[ORM\OneToMany(targetEntity: Course::class, mappedBy: 'club')]
private $courses;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\OneToOne(targetEntity: Address::class, cascade: ['persist', 'remove'])]
private $address;
#[ORM\Column(type: 'datetime_immutable', nullable: true, options: ['default' => 'CURRENT_TIMESTAMP'])]
private $createdAt;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image = null;
#[ORM\ManyToOne(targetEntity: Coach::class, inversedBy: 'createdClubInfos')]
#[ORM\JoinColumn(nullable: true)]
private ?Coach $createdByCoach = null;
#[ORM\ManyToOne(targetEntity: Operator::class, inversedBy: 'createdClubInfos')]
#[ORM\JoinColumn(nullable: true)]
private ?Operator $createdByOperator = null;
public function __construct()
{
$this->courtInfos = new ArrayCollection();
$this->courses = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSwimmingpool(): ?bool
{
return $this->swimmingpool;
}
public function setSwimmingpool(bool $swimmingpool): self
{
$this->swimmingpool = $swimmingpool;
return $this;
}
public function getGym(): ?bool
{
return $this->gym;
}
public function setGym(bool $gym): self
{
$this->gym = $gym;
return $this;
}
public function getRestaurant(): ?bool
{
return $this->restaurant;
}
public function setRestaurant(bool $restaurant): self
{
$this->restaurant = $restaurant;
return $this;
}
public function getBar(): ?bool
{
return $this->bar;
}
public function setBar(bool $bar): self
{
$this->bar = $bar;
return $this;
}
public function getSeminarRoom(): ?bool
{
return $this->seminarRoom;
}
public function setSeminarRoom(bool $seminarRoom): self
{
$this->seminarRoom = $seminarRoom;
return $this;
}
public function getInsurance(): ?bool
{
return $this->insurance;
}
public function setInsurance(bool $insurance): self
{
$this->insurance = $insurance;
return $this;
}
public function getOwner(): ?Club
{
return $this->owner;
}
public function setOwner(?Club $owner): self
{
// unset the owning side of the relation if necessary
if ($owner === null && $this->owner !== null) {
$this->owner->setClubInfo(null);
}
// set the owning side of the relation if necessary
if ($owner !== null && $owner->getClubInfo() !== $this) {
$owner->setClubInfo($this);
}
$this->owner = $owner;
return $this;
}
/**
* @return Collection|CourtInfo[]
*/
public function getCourtInfos(): Collection
{
return $this->courtInfos;
}
public function addCourtInfo(CourtInfo $courtInfo): self
{
if (!$this->courtInfos->contains($courtInfo)) {
$this->courtInfos[] = $courtInfo;
$courtInfo->setClubInfo($this);
}
return $this;
}
public function removeCourtInfo(CourtInfo $courtInfo): self
{
if ($this->courtInfos->removeElement($courtInfo)) {
// set the owning side to null (unless already changed)
if ($courtInfo->getClubInfo() === $this) {
$courtInfo->setClubInfo(null);
}
}
return $this;
}
/**
* @return Collection|Course[]
*/
public function getCourses(): Collection
{
return $this->courses;
}
public function addCourse(Course $course): self
{
if (!$this->courses->contains($course)) {
$this->courses[] = $course;
$course->setClub($this);
}
return $this;
}
public function removeCourse(Course $course): self
{
if ($this->courses->removeElement($course)) {
// set the owning side to null (unless already changed)
if ($course->getClub() === $this) {
$course->setClub(null);
}
}
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getAddress(): ?Address
{
return $this->address;
}
public function setAddress(?Address $address): self
{
$this->address = $address;
return $this;
}
public function hasCourtInfo()
{
$exist = false;
/** @var CourtInfo $court */
foreach ($this->courtInfos as $court)
{
if ($court->getNbCovered() != null || $court->getNbCovered() != 0)
{
$exist = true;
}
if ($court->getNbSemiOpen() != null || $court->getNbSemiOpen() != 0)
{
$exist = true;
}
if ($court->getNbOpen() != null || $court->getNbOpen() != 0)
{
$exist = true;
}
}
return $exist;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): static
{
$this->image = $image;
return $this;
}
public function getCreatedByCoach(): ?Coach
{
return $this->createdByCoach;
}
public function setCreatedByCoach(?Coach $createdByCoach): self
{
$this->createdByCoach = $createdByCoach;
return $this;
}
public function getCreatedByOperator(): ?Operator
{
return $this->createdByOperator;
}
public function setCreatedByOperator(?Operator $createdByOperator): self
{
$this->createdByOperator = $createdByOperator;
return $this;
}
}