<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\OperatorInfoRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
#[ORM\Entity(repositoryClass: OperatorInfoRepository::class)]
class OperatorInfo
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\OneToOne(targetEntity: Operator::class, inversedBy: 'operatorInfo', cascade: ['persist', 'remove'])]
private $owner;
#[ORM\OneToMany(mappedBy: 'operator', targetEntity: Course::class)]
private Collection $associatedCourses;
public function __construct()
{
$this->associatedCourses = 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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getOwner(): ?Operator
{
return $this->owner;
}
public function setOwner(Operator $owner): self
{
$this->owner = $owner;
return $this;
}
/**
* @return Collection<int, Course>
*/
public function getAssociatedCourses(): Collection
{
return $this->associatedCourses;
}
public function addAssociatedCourse(Course $associatedCourse): static
{
if (!$this->associatedCourses->contains($associatedCourse)) {
$this->associatedCourses->add($associatedCourse);
$associatedCourse->setOperator($this);
}
return $this;
}
public function removeAssociatedCourse(Course $associatedCourse): static
{
if ($this->associatedCourses->removeElement($associatedCourse)) {
// set the owning side to null (unless already changed)
if ($associatedCourse->getOperator() === $this) {
$associatedCourse->setOperator(null);
}
}
return $this;
}
}