src/Entity/Tutoring/Branch.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Tutoring;
  3. use App\Repository\Tutoring\BranchRepository;
  4. use App\Traits\Actions;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use ApiPlatform\Core\Annotation\ApiResource;
  8. /**
  9.  * Branch
  10.  */
  11. #[ORM\Entity(repositoryClassBranchRepository::class)]
  12. #[ORM\Table(name'hs_tc_tutoring_branch')]
  13. #[ApiResource]
  14. class Branch implements \Stringable
  15. {
  16.     use Actions;
  17.     /**
  18.      * @var string
  19.      */
  20.     #[ORM\Column(name'name'type'string'length255)]
  21.     private $name;
  22.     #[ORM\OneToMany(mappedBy'branch'targetEntityLevel::class, cascade: ['persist'], orphanRemovaltrue)]
  23.     private ?Collection $levels null;
  24.     public function __construct()
  25.     {
  26.         
  27.         $this->createAt=new \DateTime('now');
  28.         $this->published=true;
  29.     }
  30. //    /**
  31. //     * Get id
  32. //     *
  33. //     * @return integer
  34. //     */
  35. //    public function getId()
  36. //    {
  37. //        return $this->id;
  38. //    }
  39. //
  40.     /**
  41.      * Set nom
  42.      *
  43.      * @param string $name
  44.      * @return Branch
  45.      */
  46.     public function setName($name)
  47.     {
  48.         $this->name $name;
  49.         return $this;
  50.     }
  51.     /**
  52.      * Get name
  53.      *
  54.      * @return string
  55.      */
  56.     public function getName()
  57.     {
  58.         return $this->name;
  59.     }
  60.     function __toString(): string
  61.     {
  62.         return $this->name;
  63.     }
  64.     /**
  65.      * Add level
  66.      *
  67.      *
  68.      * @return Branch
  69.      */
  70.     public function addLevel(Level $level)
  71.     {
  72.         $level->setBranch($this);
  73.         $this->levels[] = $level;
  74.         return $this;
  75.     }
  76.     /**
  77.      * Remove level
  78.      */
  79.     public function removeLevel(Level $level)
  80.     {
  81.         $this->levels->removeElement($level);
  82.     }
  83.     /**
  84.      * Get levels
  85.      *
  86.      * @return ArrayCollection
  87.      */
  88.     public function getLevels()
  89.     {
  90.         return $this->levels;
  91.     }
  92. }