<?phpnamespace App\Entity\Tutoring;use ApiPlatform\Core\Annotation\ApiResource;use App\Repository\Tutoring\LevelRepository;use App\Traits\Actions;use Doctrine\Common\Collections\Collection;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\ORM\Mapping as ORM;/** * Level */#[ORM\Entity(repositoryClass: LevelRepository::class)]#[ORM\Table(name: 'hs_tc_tutoring_level')]#[ApiResource]class Level implements \Stringable{ use Actions; /** * @var string */ #[ORM\Column(name: 'name', type: 'string', length: 255)] private $name; /** * @var string */ #[ORM\Column(name: 'cycle', type: 'string', length: 255)] private $cycle; #[ORM\ManyToOne(targetEntity: Branch::class, cascade: ['persist'], inversedBy: 'levels')] private ?Branch $branch = null; #[ORM\ManyToMany(targetEntity: Course::class, mappedBy: "levels", cascade: ['persist'])] private ?Collection $courses = null; public function __construct() { $this->createAt=new \DateTime('now'); $this->published=true; } /** * Set nom * * @param string $name * @return Level */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } function __toString(): string { return $this->name.' - '.$this->cycle.' - '.$this->branch; } /** * Set cycle * * @param string $cycle * * @return Level */ public function setCycle($cycle) { $this->cycle = $cycle; return $this; } /** * Get cycle * * @return string */ public function getCycle() { return $this->cycle; } /** * Set branch * * * @return Level */ public function setBranch(Branch $branch = null) { $this->branch = $branch; return $this; } /** * Get branch * * @return Branch */ public function getBranch() { return $this->branch; } /** * Add course * * * @return Level */ public function addCourse(Course $course) { $course->addLevel($this); $this->courses[] = $course; return $this; } /** * Remove course */ public function removeCourse(Course $course) { $this->courses->removeElement($course); } /** * Get courses * * @return ArrayCollection */ public function getCourses() { return $this->courses; }}