src/Entity/Tutoring/Level.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Tutoring;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Tutoring\LevelRepository;
  5. use App\Traits\Actions;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * Level
  11.  */
  12. #[ORM\Entity(repositoryClassLevelRepository::class)]
  13. #[ORM\Table(name'hs_tc_tutoring_level')]
  14. #[ApiResource]
  15. class Level implements \Stringable
  16. {
  17.     use Actions;
  18.     /**
  19.      * @var string
  20.      */
  21.     #[ORM\Column(name'name'type'string'length255)]
  22.     private $name;
  23.     /**
  24.      * @var string
  25.      */
  26.     #[ORM\Column(name'cycle'type'string'length255)]
  27.     private $cycle;
  28.     #[ORM\ManyToOne(targetEntityBranch::class, cascade: ['persist'], inversedBy'levels')]
  29.     private ?Branch $branch null;
  30.     #[ORM\ManyToMany(targetEntityCourse::class, mappedBy"levels"cascade: ['persist'])]
  31.     private ?Collection $courses null;
  32.     public function __construct()
  33.     {
  34.         
  35.         $this->createAt=new \DateTime('now');
  36.         $this->published=true;
  37.     }
  38.     /**
  39.      * Set nom
  40.      *
  41.      * @param string $name
  42.      * @return Level
  43.      */
  44.     public function setName($name)
  45.     {
  46.         $this->name $name;
  47.         return $this;
  48.     }
  49.     /**
  50.      * Get name
  51.      *
  52.      * @return string 
  53.      */
  54.     public function getName()
  55.     {
  56.         return $this->name;
  57.     }
  58.     function __toString(): string
  59.     {
  60.         return $this->name.' - '.$this->cycle.' - '.$this->branch;
  61.     }
  62.     /**
  63.      * Set cycle
  64.      *
  65.      * @param string $cycle
  66.      *
  67.      * @return Level
  68.      */
  69.     public function setCycle($cycle)
  70.     {
  71.         $this->cycle $cycle;
  72.         return $this;
  73.     }
  74.     /**
  75.      * Get cycle
  76.      *
  77.      * @return string
  78.      */
  79.     public function getCycle()
  80.     {
  81.         return $this->cycle;
  82.     }
  83.     /**
  84.      * Set branch
  85.      *
  86.      *
  87.      * @return Level
  88.      */
  89.     public function setBranch(Branch $branch null)
  90.     {
  91.         $this->branch $branch;
  92.         return $this;
  93.     }
  94.     /**
  95.      * Get branch
  96.      *
  97.      * @return Branch
  98.      */
  99.     public function getBranch()
  100.     {
  101.         return $this->branch;
  102.     }
  103.     /**
  104.      * Add course
  105.      *
  106.      *
  107.      * @return Level
  108.      */
  109.     public function addCourse(Course $course)
  110.     {
  111.         $course->addLevel($this);
  112.         $this->courses[] = $course;
  113.         return $this;
  114.     }
  115.     /**
  116.      * Remove course
  117.      */
  118.     public function removeCourse(Course $course)
  119.     {
  120.         $this->courses->removeElement($course);
  121.     }
  122.     /**
  123.      * Get courses
  124.      *
  125.      * @return ArrayCollection
  126.      */
  127.     public function getCourses()
  128.     {
  129.         return $this->courses;
  130.     }
  131. }