<?phpnamespace App\Entity\Formation;use ApiPlatform\Core\Annotation\ApiResource;use App\Repository\Formation\UniteRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping\Entity;use Doctrine\ORM\Mapping\ManyToOne;use Doctrine\ORM\Mapping\JoinColumn;use App\Traits\Actions;use Doctrine\ORM\Mapping as ORM;#[Entity(repositoryClass: UniteRepository::class)]#[ORM\Table(name: 'hs_tc_formation_unite')]#[ApiResource]class Unite implements \Stringable{ use Actions; #[ORM\Column(name: "ref", type: "string", length: 255)] private ?string $ref = null; #[ORM\Column(name: "name", type: "string", length: 255)] private $name; #[ManyToOne(targetEntity: "Activity", inversedBy: "unites")] #[JoinColumn(nullable: false)] private ?Activity $activity = null; #[ORM\Column(name: "semester", type: "string", length: 255, nullable: true)] private ?string $semester = null; #[ORM\OneToMany(mappedBy: "unite", targetEntity: "Attribution")] private ?Collection $attributions = null; #[ORM\Column()] private ?int $hourlyVolume = null; public function __construct() { // date_default_timezone_set('Africa/Casablanca'); $this->createAt=new \DateTime('now'); $this->published=false; } /** * @return string */ public function getRef(): ?string { return $this->ref; } /** * @param string $ref */ public function setRef(?string $ref): Unite { $this->ref = $ref; return $this; } /** * Set nom * * @param string $name * @return Unite */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } function __toString(): string { return (string) $this->name; } /** * @return Activity */ public function getActivity(): ?Activity { return $this->activity; } /** * @param Activity $activity */ public function setActivity(?Activity $activity): Unite { $this->activity = $activity; return $this; } /** * Add attribution * * * @return Unite */ public function addAttribution(Attribution $attribution) { $attribution->setUnite($this); $this->attributions[] = $attribution; return $this; } /** * Remove attribution */ public function removeAttribution(Attribution $attribution) { $this->attributions->removeElement($attribution); } /** * Get attributions * * @return Collection */ public function getAttributions() { return $this->attributions; } public function getHourlyVolume(): ?int { return $this->hourlyVolume; } public function setHourlyVolume(?int $hourlyVolume): void { $this->hourlyVolume = $hourlyVolume; } public function getIntervenantClasse(Classe $classe): ?\App\Entity\Formation\Intervenant{ $intervenant=null; /** @var Attribution $attribution */ foreach ($this->getAttributions() as $attribution){ if($attribution->getClasse()===$classe) $intervenant=$attribution->getIntervenant(); } return $intervenant; }}