src/Entity/Partnership.php line 8

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. #[ORM\Entity]
  5. class Partnership
  6. {
  7.     #[ORM\Id]
  8.     #[ORM\GeneratedValue]
  9.     #[ORM\Column(type'integer')]
  10.     private $id;
  11.     #[ORM\ManyToOne(targetEntityCoach::class, inversedBy'partnerships')]
  12.     private $coach;
  13.     #[ORM\ManyToOne(targetEntityClub::class, inversedBy'partnerships')]
  14.     private $club;
  15.     #[ORM\ManyToOne(targetEntityOperator::class, inversedBy'partnerships')]
  16.     private $operator;
  17.     #[ORM\Column(type'string'length255)]
  18.     private $status;
  19.     #[ORM\Column(type'datetime')]
  20.     private $requestDate;
  21.     #[ORM\Column(type'datetime'nullabletrue)]
  22.     private $acceptedDate;
  23.     #[ORM\ManyToOne(targetEntityUser::class)]
  24.     private $requestedBy;
  25.     // Getters and Setters
  26.     public function getOtherPro($currentPro)
  27.     {
  28.         // Si le pro connecté est le coach dans le partenariat
  29.         if ($this->getCoach() === $currentPro) {
  30.             return $this->getClub() ?? $this->getOperator();
  31.         }
  32.         // Si le pro connecté est le club dans le partenariat
  33.         if ($this->getClub() === $currentPro) {
  34.             return $this->getCoach() ?? $this->getOperator();
  35.         }
  36.         // Si le pro connecté est l'opérateur dans le partenariat
  37.         if ($this->getOperator() === $currentPro) {
  38.             return $this->getCoach() ?? $this->getClub();
  39.         }
  40.         // Vérifier qui a initié la demande (si ce n'est pas le pro connecté)
  41.         if ($this->getRequestedBy() !== $currentPro) {
  42.             if ($this->getCoach() !== $currentPro) {
  43.                 return $this->getCoach();
  44.             } elseif ($this->getClub() !== $currentPro) {
  45.                 return $this->getClub();
  46.             } elseif ($this->getOperator() !== $currentPro) {
  47.                 return $this->getOperator();
  48.             }
  49.         }
  50.         return null// Si le pro n'est pas impliqué ou aucune autre condition ne s'applique
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getCoach(): ?Coach
  57.     {
  58.         return $this->coach;
  59.     }
  60.     public function setCoach(?Coach $coach): self
  61.     {
  62.         $this->coach $coach;
  63.         return $this;
  64.     }
  65.     public function getClub(): ?Club
  66.     {
  67.         return $this->club;
  68.     }
  69.     public function setClub(?Club $club): self
  70.     {
  71.         $this->club $club;
  72.         return $this;
  73.     }
  74.     public function getOperator(): ?Operator
  75.     {
  76.         return $this->operator;
  77.     }
  78.     public function setOperator(?Operator $operator): self
  79.     {
  80.         $this->operator $operator;
  81.         return $this;
  82.     }
  83.     public function getStatus(): ?string
  84.     {
  85.         return $this->status;
  86.     }
  87.     public function setStatus(string $status): self
  88.     {
  89.         $this->status $status;
  90.         return $this;
  91.     }
  92.     public function getRequestDate(): ?\DateTimeInterface
  93.     {
  94.         return $this->requestDate;
  95.     }
  96.     public function setRequestDate(\DateTimeInterface $requestDate): self
  97.     {
  98.         $this->requestDate $requestDate;
  99.         return $this;
  100.     }
  101.     public function getAcceptedDate(): ?\DateTimeInterface
  102.     {
  103.         return $this->acceptedDate;
  104.     }
  105.     public function setAcceptedDate(?\DateTimeInterface $acceptedDate): self
  106.     {
  107.         $this->acceptedDate $acceptedDate;
  108.         return $this;
  109.     }
  110.     public function getRequestedBy(): ?User
  111.     {
  112.         return $this->requestedBy;
  113.     }
  114.     public function setRequestedBy(?User $requestedBy): self
  115.     {
  116.         $this->requestedBy $requestedBy;
  117.         return $this;
  118.     }
  119. }