<?php
namespace App\Entity;
use App\Repository\CourseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CourseRepository::class)]
class Course
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\ManyToOne(targetEntity: ClubInfo::class, inversedBy: 'courses', fetch: "EAGER")]
private $club;
#[ORM\OneToOne(targetEntity: Address::class, inversedBy: 'course', cascade: ['persist', 'remove'])]
private $address;
#[ORM\OneToMany(targetEntity: Photo::class, mappedBy: 'course', cascade: ['persist', 'remove'])]
private $photos;
#[ORM\OneToMany(targetEntity: Video::class, mappedBy: 'course', cascade: ['persist', 'remove'])]
private $videos;
#[ORM\Column(type: 'array', nullable: true)]
private $logistic = [];
#[ORM\OneToMany(targetEntity: Airport::class, mappedBy: 'course', cascade: ['persist', 'remove'], orphanRemoval: true)]
private $airports;
#[ORM\OneToMany(targetEntity: Beach::class, mappedBy: 'course', cascade: ['persist', 'remove'], orphanRemoval: true)]
private $beaches;
#[ORM\OneToMany(targetEntity: Station::class, mappedBy: 'course', cascade: ['persist', 'remove'], orphanRemoval: true)]
private $stations;
#[ORM\OneToMany(targetEntity: Restaurant::class, mappedBy: 'course', cascade: ['persist', 'remove'], orphanRemoval: true)]
private $restaurants;
#[ORM\OneToMany(targetEntity: Accommodation::class, mappedBy: 'course', cascade: ['persist', 'remove'], orphanRemoval: true)]
private $accommodations;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'courses')]
private $owner;
#[ORM\ManyToMany(targetEntity: Sport::class, inversedBy: 'courses')]
private $sports;
#[ORM\OneToMany(targetEntity: CourseAvailability::class, mappedBy: 'course', cascade: ['persist', 'remove'])]
private $availabilities;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $frequency;
#[ORM\ManyToMany(targetEntity: Language::class, inversedBy: 'courses')]
private $languages;
#[ORM\OneToMany(targetEntity: FeaturedCourse::class, mappedBy: 'course')]
private $featureds;
#[ORM\Column(type: 'string', length: 255)]
private $status;
#[ORM\Column(type: 'datetime', nullable: true)]
private $createdAt;
#[ORM\ManyToMany(targetEntity: Age::class, inversedBy: 'courses')]
private $ages;
#[ORM\ManyToMany(targetEntity: Level::class, inversedBy: 'courses')]
private $levels;
#[ORM\ManyToMany(targetEntity: Trainee::class, mappedBy: 'favorites')]
private $traineesFavorites;
#[ORM\OneToMany(targetEntity: TranslatedCourse::class, mappedBy: 'course', cascade: ['persist', 'remove'])]
private $translatedContents;
#[ORM\Column(type: 'string', length: 255)]
private $token;
#[ORM\OneToMany(targetEntity: Booking::class, mappedBy: 'course')]
private $bookings;
#[ORM\Column(type: 'string', length: 255)]
private $countryCode;
#[ORM\Column(type: 'float', nullable: true)]
private $latitude;
#[ORM\Column(type: 'float', nullable: true)]
private $longitude;
#[ORM\OneToMany(targetEntity: CourseViewsStat::class, mappedBy: 'course', cascade: ['persist', 'remove'])]
private $courseViewsStats;
#[ORM\Column(type: 'boolean')]
private $hideClubInfo;
#[ORM\Column(type: 'boolean')]
private $hideCoachInfo;
#[ORM\Column(type: 'integer', length: 255, nullable: true)]
private $stepSaved;
#[ORM\ManyToMany(targetEntity: CoachInfo::class, inversedBy: 'courses')]
private $coachsInfos;
#[ORM\Column(type: 'boolean', nullable: true)]
private $sendedAlert;
#[ORM\Column(length: 255, nullable: true)]
private ?string $cover = null;
#[ORM\OneToMany(mappedBy: 'course', targetEntity: PriceBundle::class)]
private Collection $priceBundles;
private $translateName;
private $translateDescription;
private $translatePlanning;
private $translateOther;
#[ORM\Column(nullable: true)]
private ?bool $visibleToClub = true;
#[ORM\Column(nullable: true)]
private ?bool $visibleToCoach = true;
#[ORM\Column(nullable: true)]
private ?bool $visibleToOperator = true;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $publishedAt = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $updatedAt = null;
#[ORM\ManyToOne(inversedBy: 'associatedCourses')]
private ?OperatorInfo $operator = null;
#[ORM\OneToMany(mappedBy: 'course', targetEntity: NoteRequest::class)]
private Collection $noteRequests;
#[ORM\OneToMany(mappedBy: 'course', targetEntity: Note::class)]
private Collection $notes;
public function __construct()
{
$this->photos = new ArrayCollection();
$this->videos = new ArrayCollection();
$this->airports = new ArrayCollection();
$this->beaches = new ArrayCollection();
$this->stations = new ArrayCollection();
$this->restaurants = new ArrayCollection();
$this->accommodations = new ArrayCollection();
$this->sports = new ArrayCollection();
$this->availabilities = new ArrayCollection();
$this->languages = new ArrayCollection();
$this->featureds = new ArrayCollection();
$this->ages = new ArrayCollection();
$this->levels = new ArrayCollection();
$this->traineesFavorites = new ArrayCollection();
$this->translatedContents = new ArrayCollection();
$this->bookings = new ArrayCollection();
$this->courseViewsStats = new ArrayCollection();
$this->coachsInfos = new ArrayCollection();
$this->priceBundles = new ArrayCollection();
$this->noteRequests = new ArrayCollection();
$this->notes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getClub(): ?ClubInfo
{
return $this->club;
}
public function setClub(?ClubInfo $club): self
{
$this->club = $club;
return $this;
}
public function getAddress(): ?Address
{
return $this->address;
}
public function setAddress(?Address $address): self
{
$this->address = $address;
return $this;
}
/**
* @return Collection|Photo[]
*/
public function getPhotos(): Collection
{
return $this->photos;
}
public function addPhoto(Photo $photo): self
{
if (!$this->photos->contains($photo)) {
$this->photos[] = $photo;
$photo->setCourse($this);
}
return $this;
}
public function removePhoto(Photo $photo): self
{
if ($this->photos->removeElement($photo)) {
// set the owning side to null (unless already changed)
if ($photo->getCourse() === $this) {
$photo->setCourse(null);
}
}
return $this;
}
/**
* @return Collection|Video[]
*/
public function getVideos(): Collection
{
return $this->videos;
}
public function addVideo(Video $video): self
{
if (!$this->videos->contains($video)) {
$this->videos[] = $video;
$video->setCourse($this);
}
return $this;
}
public function removeVideo(Video $video): self
{
if ($this->videos->removeElement($video)) {
// set the owning side to null (unless already changed)
if ($video->getCourse() === $this) {
$video->setCourse(null);
}
}
return $this;
}
public function getLogistic(): ?array
{
return $this->logistic;
}
public function setLogistic(?array $logistic): self
{
$this->logistic = $logistic;
return $this;
}
/**
* @return Collection|Airport[]
*/
public function getAirports(): Collection
{
return $this->airports;
}
public function addAirport(Airport $airport): self
{
if (!$this->airports->contains($airport)) {
$this->airports[] = $airport;
$airport->setCourse($this);
}
return $this;
}
public function removeAirport(Airport $airport): self
{
if ($this->airports->removeElement($airport)) {
// set the owning side to null (unless already changed)
if ($airport->getCourse() === $this) {
$airport->setCourse(null);
}
}
return $this;
}
/**
* @return Collection|Beach[]
*/
public function getBeaches(): Collection
{
return $this->beaches;
}
public function addBeach(Beach $beach): self
{
if (!$this->beaches->contains($beach)) {
$this->beaches[] = $beach;
$beach->setCourse($this);
}
return $this;
}
public function removeBeach(Beach $beach): self
{
if ($this->beaches->removeElement($beach)) {
// set the owning side to null (unless already changed)
if ($beach->getCourse() === $this) {
$beach->setCourse(null);
}
}
return $this;
}
/**
* @return Collection|Station[]
*/
public function getStations(): Collection
{
return $this->stations;
}
public function addStation(Station $station): self
{
if (!$this->stations->contains($station)) {
$this->stations[] = $station;
$station->setCourse($this);
}
return $this;
}
public function removeStation(Station $station): self
{
if ($this->stations->removeElement($station)) {
// set the owning side to null (unless already changed)
if ($station->getCourse() === $this) {
$station->setCourse(null);
}
}
return $this;
}
/**
* @return Collection|Restaurant[]
*/
public function getRestaurants(): Collection
{
return $this->restaurants;
}
public function addRestaurant(Restaurant $restaurant): self
{
if (!$this->restaurants->contains($restaurant)) {
$this->restaurants[] = $restaurant;
$restaurant->setCourse($this);
}
return $this;
}
public function removeRestaurant(Restaurant $restaurant): self
{
if ($this->restaurants->removeElement($restaurant)) {
// set the owning side to null (unless already changed)
if ($restaurant->getCourse() === $this) {
$restaurant->setCourse(null);
}
}
return $this;
}
/**
* @return Collection|Accommodation[]
*/
public function getAccommodations(): Collection
{
return $this->accommodations;
}
public function addAccommodation(Accommodation $accommodation): self
{
if (!$this->accommodations->contains($accommodation)) {
$this->accommodations[] = $accommodation;
$accommodation->setCourse($this);
}
return $this;
}
public function removeAccommodation(Accommodation $accommodation): self
{
if ($this->accommodations->removeElement($accommodation)) {
// set the owning side to null (unless already changed)
if ($accommodation->getCourse() === $this) {
$accommodation->setCourse(null);
}
}
return $this;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): self
{
$this->owner = $owner;
return $this;
}
/**
* @return Collection|Sport[]
*/
public function getSports(): Collection
{
return $this->sports;
}
public function addSport(Sport $sport): self
{
if (!$this->sports->contains($sport)) {
$this->sports[] = $sport;
}
return $this;
}
public function removeSport(Sport $sport): self
{
$this->sports->removeElement($sport);
return $this;
}
/**
* @return Collection|CourseAvailability[]
*/
public function getAvailabilities(): Collection
{
return $this->availabilities;
}
public function addAvailability(CourseAvailability $availability): self
{
if (!$this->availabilities->contains($availability)) {
$this->availabilities[] = $availability;
$availability->setCourse($this);
}
return $this;
}
public function removeAvailability(CourseAvailability $availability): self
{
if ($this->availabilities->removeElement($availability)) {
// set the owning side to null (unless already changed)
if ($availability->getCourse() === $this) {
$availability->setCourse(null);
}
}
return $this;
}
public function getFrequency(): ?string
{
return $this->frequency;
}
public function setFrequency(string $frequency): self
{
$this->frequency = $frequency;
return $this;
}
/**
* @return Collection|Language[]
*/
public function getLanguages(): Collection
{
return $this->languages;
}
public function addLanguage(Language $language): self
{
if (!$this->languages->contains($language)) {
$this->languages[] = $language;
}
return $this;
}
public function removeLanguage(Language $language): self
{
$this->languages->removeElement($language);
return $this;
}
/**
* @return Collection|FeaturedCourse[]
*/
public function getFeatureds(): Collection
{
return $this->featureds;
}
public function addFeatured(FeaturedCourse $featured): self
{
if (!$this->featureds->contains($featured)) {
$this->featureds[] = $featured;
$featured->setCourse($this);
}
return $this;
}
public function removeFeatured(FeaturedCourse $featured): self
{
if ($this->featureds->removeElement($featured)) {
// set the owning side to null (unless already changed)
if ($featured->getCourse() === $this) {
$featured->setCourse(null);
}
}
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return Collection|Age[]
*/
public function getAges(): Collection
{
return $this->ages;
}
public function addAge(Age $age): self
{
if (!$this->ages->contains($age)) {
$this->ages[] = $age;
}
return $this;
}
public function removeAge(Age $age): self
{
$this->ages->removeElement($age);
return $this;
}
/**
* @return Collection|Level[]
*/
public function getLevels(): Collection
{
return $this->levels;
}
public function addLevel(Level $level): self
{
if (!$this->levels->contains($level)) {
$this->levels[] = $level;
}
return $this;
}
public function removeLevel(Level $level): self
{
$this->levels->removeElement($level);
return $this;
}
/**
* @return Collection|Trainee[]
*/
public function getTraineesFavorites(): Collection
{
return $this->traineesFavorites;
}
public function addTraineesFavorite(Trainee $traineesFavorite): self
{
if (!$this->traineesFavorites->contains($traineesFavorite)) {
$this->traineesFavorites[] = $traineesFavorite;
$traineesFavorite->addFavorite($this);
}
return $this;
}
public function removeTraineesFavorite(Trainee $traineesFavorite): self
{
if ($this->traineesFavorites->removeElement($traineesFavorite)) {
$traineesFavorite->removeFavorite($this);
}
return $this;
}
/**
* @return Collection|TranslatedCourse[]
*/
public function getTranslatedContents(): Collection
{
return $this->translatedContents;
}
public function addTranslatedContent(TranslatedCourse $translatedContent): self
{
if (!$this->translatedContents->contains($translatedContent)) {
$this->translatedContents[] = $translatedContent;
$translatedContent->setCourse($this);
}
return $this;
}
public function removeTranslatedContent(TranslatedCourse $translatedContent): self
{
if ($this->translatedContents->removeElement($translatedContent)) {
// set the owning side to null (unless already changed)
if ($translatedContent->getCourse() === $this) {
$translatedContent->setCourse(null);
}
}
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(string $token): self
{
$this->token = $token;
return $this;
}
public function getTranslatedContent($local)
{
foreach($this->translatedContents as $translatedCourse)
{
if($translatedCourse->getLanguage() == $local)
{
return $translatedCourse;
}
}
foreach($this->translatedContents as $translatedCourse)
{
if($translatedCourse->getLanguage() == 'en')
{
return $translatedCourse;
}
}
return $this->getTranslatedContents()->first() ?? null;
}
/**
* @return Collection|Booking[]
*/
public function getBookings(): Collection
{
return $this->bookings;
}
public function addBooking(Booking $booking): self
{
if (!$this->bookings->contains($booking)) {
$this->bookings[] = $booking;
$booking->setCourse($this);
}
return $this;
}
public function removeBooking(Booking $booking): self
{
if ($this->bookings->removeElement($booking)) {
// set the owning side to null (unless already changed)
if ($booking->getCourse() === $this) {
$booking->setCourse(null);
}
}
return $this;
}
public function getCountryCode(): ?string
{
return $this->countryCode;
}
public function setCountryCode(string $countryCode): self
{
$this->countryCode = $countryCode;
return $this;
}
public function getLatitude(): ?float
{
return $this->latitude;
}
public function setLatitude(?float $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): ?float
{
return $this->longitude;
}
public function setLongitude(?float $longitude): self
{
$this->longitude = $longitude;
return $this;
}
/**
* @return Collection|CourseViewsStat[]
*/
public function getCourseViewsStats(): Collection
{
return $this->courseViewsStats;
}
public function addCourseViewsStat(CourseViewsStat $courseViewsStat): self
{
if (!$this->courseViewsStats->contains($courseViewsStat)) {
$this->courseViewsStats[] = $courseViewsStat;
$courseViewsStat->setCourse($this);
}
return $this;
}
public function removeCourseViewsStat(CourseViewsStat $courseViewsStat): self
{
if ($this->courseViewsStats->removeElement($courseViewsStat)) {
// set the owning side to null (unless already changed)
if ($courseViewsStat->getCourse() === $this) {
$courseViewsStat->setCourse(null);
}
}
return $this;
}
public function getHideClubInfo(): ?bool
{
return $this->hideClubInfo;
}
public function setHideClubInfo(bool $hideClubInfo): self
{
$this->hideClubInfo = $hideClubInfo;
return $this;
}
public function getHideCoachInfo(): ?bool
{
return $this->hideCoachInfo;
}
public function setHideCoachInfo(bool $hideCoachInfo): self
{
$this->hideCoachInfo = $hideCoachInfo;
return $this;
}
public function getStepSaved(): ?int
{
return $this->stepSaved;
}
public function setStepSaved(?int $stepSaved): self
{
$this->stepSaved = $stepSaved;
return $this;
}
/**
* @return Collection<int, CoachInfo>
*/
public function getCoachsInfos(): Collection
{
return $this->coachsInfos;
}
public function addCoachsInfo(CoachInfo $coachsInfo): self
{
if (!$this->coachsInfos->contains($coachsInfo)) {
$this->coachsInfos[] = $coachsInfo;
}
return $this;
}
public function removeCoachsInfo(CoachInfo $coachsInfo): self
{
$this->coachsInfos->removeElement($coachsInfo);
return $this;
}
public function getSendedAlert(): ?bool
{
return $this->sendedAlert;
}
public function setSendedAlert(?bool $sendedAlert): self
{
$this->sendedAlert = $sendedAlert;
return $this;
}
public function getCover()
{
return $this->cover;
}
public function setCover($cover): static
{
$this->cover = $cover;
return $this;
}
/**
* @return Collection<int, PriceBundle>
*/
public function getPriceBundles(): Collection
{
return $this->priceBundles;
}
public function addPriceBundle(PriceBundle $priceBundle): static
{
if (!$this->priceBundles->contains($priceBundle)) {
$this->priceBundles->add($priceBundle);
$priceBundle->setCourse($this);
}
return $this;
}
public function removePriceBundle(PriceBundle $priceBundle): static
{
if ($this->priceBundles->removeElement($priceBundle)) {
// set the owning side to null (unless already changed)
if ($priceBundle->getCourse() === $this) {
$priceBundle->setCourse(null);
}
}
return $this;
}
/**
* Get the value of translateName
*/
public function getTranslateName()
{
return $this->translateName;
}
/**
* Set the value of translateName
*
* @return self
*/
public function setTranslateName($translateName)
{
$this->translateName = $translateName;
return $this;
}
/**
* Get the value of translateDescription
*/
public function getTranslateDescription()
{
return $this->translateDescription;
}
/**
* Set the value of translateDescription
*
* @return self
*/
public function setTranslateDescription($translateDescription)
{
$this->translateDescription = $translateDescription;
return $this;
}
/**
* Get the value of translatePlanning
*/
public function getTranslatePlanning()
{
return $this->translatePlanning;
}
/**
* Set the value of translatePlanning
*
* @return self
*/
public function setTranslatePlanning($translatePlanning)
{
$this->translatePlanning = $translatePlanning;
return $this;
}
/**
* Get the value of translateOther
*/
public function getTranslateOther()
{
return $this->translateOther;
}
/**
* Set the value of translateOther
*
* @return self
*/
public function setTranslateOther($translateOther)
{
$this->translateOther = $translateOther;
return $this;
}
public function isVisibleToClub(): ?bool
{
return $this->visibleToClub;
}
public function setVisibleToClub(?bool $visibleToClub): static
{
$this->visibleToClub = $visibleToClub;
return $this;
}
public function isVisibleToCoach(): ?bool
{
return $this->visibleToCoach;
}
public function setVisibleToCoach(?bool $visibleToCoach): static
{
$this->visibleToCoach = $visibleToCoach;
return $this;
}
public function isVisibleToOperator(): ?bool
{
return $this->visibleToOperator;
}
public function setVisibleToOperator(?bool $visibleToOperator): static
{
$this->visibleToOperator = $visibleToOperator;
return $this;
}
public function getPublishedAt(): ?\DateTimeInterface
{
return $this->publishedAt;
}
public function setPublishedAt(?\DateTimeInterface $publishedAt): static
{
$this->publishedAt = $publishedAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getOperator(): ?OperatorInfo
{
return $this->operator;
}
public function setOperator(?OperatorInfo $operator): static
{
$this->operator = $operator;
return $this;
}
/**
* @return Collection<int, NoteRequest>
*/
public function getNoteRequests(): Collection
{
return $this->noteRequests;
}
public function addNoteRequest(NoteRequest $noteRequest): static
{
if (!$this->noteRequests->contains($noteRequest)) {
$this->noteRequests->add($noteRequest);
$noteRequest->setCourse($this);
}
return $this;
}
public function removeNoteRequest(NoteRequest $noteRequest): static
{
if ($this->noteRequests->removeElement($noteRequest)) {
// set the owning side to null (unless already changed)
if ($noteRequest->getCourse() === $this) {
$noteRequest->setCourse(null);
}
}
return $this;
}
/**
* @return Collection<int, Note>
*/
public function getNotes(): Collection
{
return $this->notes;
}
public function addNote(Note $note): static
{
if (!$this->notes->contains($note)) {
$this->notes->add($note);
$note->setCourse($this);
}
return $this;
}
public function removeNote(Note $note): static
{
if ($this->notes->removeElement($note)) {
// set the owning side to null (unless already changed)
if ($note->getCourse() === $this) {
$note->setCourse(null);
}
}
return $this;
}
}