src/Entity/Formation/Unite.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Formation;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Formation\UniteRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping\Entity;
  8. use Doctrine\ORM\Mapping\ManyToOne;
  9. use Doctrine\ORM\Mapping\JoinColumn;
  10. use App\Traits\Actions;
  11. use Doctrine\ORM\Mapping as ORM;
  12. #[Entity(repositoryClassUniteRepository::class)]
  13. #[ORM\Table(name'hs_tc_formation_unite')]
  14. #[ApiResource]
  15. class Unite implements \Stringable
  16. {
  17.     use Actions;
  18.     #[ORM\Column(name"ref"type"string"length255)]
  19.     private ?string $ref null;
  20.     #[ORM\Column(name"name"type"string"length255)]
  21.     private $name;
  22.     #[ManyToOne(targetEntity"Activity"inversedBy"unites")]
  23.     #[JoinColumn(nullablefalse)]
  24.     private ?Activity $activity null;
  25.     #[ORM\Column(name"semester"type"string"length255nullabletrue)]
  26.     private ?string $semester null;
  27.     #[ORM\OneToMany(mappedBy"unite"targetEntity"Attribution")]
  28.     private ?Collection $attributions null;
  29.     #[ORM\Column()]
  30.     private ?int $hourlyVolume null;
  31.     public function __construct()
  32.     {
  33.         // date_default_timezone_set('Africa/Casablanca');
  34.         $this->createAt=new \DateTime('now');
  35.         $this->published=false;
  36.     }
  37.     /**
  38.      * @return string
  39.      */
  40.     public function getRef(): ?string
  41.     {
  42.         return $this->ref;
  43.     }
  44.     /**
  45.      * @param string $ref
  46.      */
  47.     public function setRef(?string $ref): Unite
  48.     {
  49.         $this->ref $ref;
  50.         return $this;
  51.     }
  52.     /**
  53.      * Set nom
  54.      *
  55.      * @param string $name
  56.      * @return Unite
  57.      */
  58.     public function setName($name)
  59.     {
  60.         $this->name $name;
  61.         return $this;
  62.     }
  63.     /**
  64.      * Get name
  65.      *
  66.      * @return string
  67.      */
  68.     public function getName()
  69.     {
  70.         return $this->name;
  71.     }
  72.     function __toString(): string
  73.     {
  74.         return (string) $this->name;
  75.     }
  76.     /**
  77.      * @return Activity
  78.      */
  79.     public function getActivity(): ?Activity
  80.     {
  81.         return $this->activity;
  82.     }
  83.     /**
  84.      * @param Activity $activity
  85.      */
  86.     public function setActivity(?Activity $activity): Unite
  87.     {
  88.         $this->activity $activity;
  89.         return $this;
  90.     }
  91.     /**
  92.      * Add attribution
  93.      *
  94.      *
  95.      * @return Unite
  96.      */
  97.     public function addAttribution(Attribution $attribution)
  98.     {
  99.         $attribution->setUnite($this);
  100.         $this->attributions[] = $attribution;
  101.         return $this;
  102.     }
  103.     /**
  104.      * Remove attribution
  105.      */
  106.     public function removeAttribution(Attribution $attribution)
  107.     {
  108.         $this->attributions->removeElement($attribution);
  109.     }
  110.     /**
  111.      * Get attributions
  112.      *
  113.      * @return Collection
  114.      */
  115.     public function getAttributions()
  116.     {
  117.         return $this->attributions;
  118.     }
  119.     public function getHourlyVolume(): ?int
  120.     {
  121.         return $this->hourlyVolume;
  122.     }
  123.     public function setHourlyVolume(?int $hourlyVolume): void
  124.     {
  125.         $this->hourlyVolume $hourlyVolume;
  126.     }
  127.     public function getIntervenantClasse(Classe $classe): ?\App\Entity\Formation\Intervenant{
  128.         $intervenant=null;
  129.         /** @var Attribution $attribution */
  130.         foreach ($this->getAttributions() as $attribution){
  131.             if($attribution->getClasse()===$classe$intervenant=$attribution->getIntervenant();
  132.         }
  133.         return $intervenant;
  134.     }
  135. }