src/Entity/CommandeFormation.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\CommandeFormationRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassCommandeFormationRepository::class)]
  7. #[ApiResource]
  8. class CommandeFormation
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\ManyToOne(inversedBy'commandeFormations')]
  15.     private ?Commande $commande null;
  16.     #[ORM\ManyToOne(inversedBy'commandeFormations')]
  17.     private ?FormationElearning $formation null;
  18.     #[ORM\ManyToOne(inversedBy'commandeFormations')]
  19.     private ?Pack $pack null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $type null;
  22.     public function getId(): ?int
  23.     {
  24.         return $this->id;
  25.     }
  26.     public function getCommande(): ?Commande
  27.     {
  28.         return $this->commande;
  29.     }
  30.     public function setCommande(?Commande $commande): self
  31.     {
  32.         $this->commande $commande;
  33.         return $this;
  34.     }
  35.     public function getFormation(): ?FormationElearning
  36.     {
  37.         return $this->formation;
  38.     }
  39.     public function setFormation(?FormationElearning $formation): self
  40.     {
  41.         $this->formation $formation;
  42.         return $this;
  43.     }
  44.     public function getPack(): ?Pack
  45.     {
  46.         return $this->pack;
  47.     }
  48.     public function setPack(?Pack $pack): self
  49.     {
  50.         $this->pack $pack;
  51.         return $this;
  52.     }
  53.     public function getType(): ?string
  54.     {
  55.         return $this->type;
  56.     }
  57.     public function setType(?string $type): self
  58.     {
  59.         $this->type $type;
  60.         return $this;
  61.     }
  62.     // Méthode utilitaire pour obtenir l'élément (formation ou pack)
  63.     public function getItem()
  64.     {
  65.         return $this->type === 'pack' $this->pack $this->formation;
  66.     }
  67.     // Méthode pour obtenir le nom de l'élément
  68.     public function getItemName(): ?string
  69.     {
  70.         if ($this->type === 'pack' && $this->pack) {
  71.             return $this->pack->getLibelle();
  72.         } elseif ($this->type === 'formation' && $this->formation) {
  73.             return $this->formation->getTitre();
  74.         }
  75.         return null;
  76.     }
  77. }