<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Partnership
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\ManyToOne(targetEntity: Coach::class, inversedBy: 'partnerships')]
private $coach;
#[ORM\ManyToOne(targetEntity: Club::class, inversedBy: 'partnerships')]
private $club;
#[ORM\ManyToOne(targetEntity: Operator::class, inversedBy: 'partnerships')]
private $operator;
#[ORM\Column(type: 'string', length: 255)]
private $status;
#[ORM\Column(type: 'datetime')]
private $requestDate;
#[ORM\Column(type: 'datetime', nullable: true)]
private $acceptedDate;
#[ORM\ManyToOne(targetEntity: User::class)]
private $requestedBy;
// Getters and Setters
public function getOtherPro($currentPro)
{
// Si le pro connecté est le coach dans le partenariat
if ($this->getCoach() === $currentPro) {
return $this->getClub() ?? $this->getOperator();
}
// Si le pro connecté est le club dans le partenariat
if ($this->getClub() === $currentPro) {
return $this->getCoach() ?? $this->getOperator();
}
// Si le pro connecté est l'opérateur dans le partenariat
if ($this->getOperator() === $currentPro) {
return $this->getCoach() ?? $this->getClub();
}
// Vérifier qui a initié la demande (si ce n'est pas le pro connecté)
if ($this->getRequestedBy() !== $currentPro) {
if ($this->getCoach() !== $currentPro) {
return $this->getCoach();
} elseif ($this->getClub() !== $currentPro) {
return $this->getClub();
} elseif ($this->getOperator() !== $currentPro) {
return $this->getOperator();
}
}
return null; // Si le pro n'est pas impliqué ou aucune autre condition ne s'applique
}
public function getId(): ?int
{
return $this->id;
}
public function getCoach(): ?Coach
{
return $this->coach;
}
public function setCoach(?Coach $coach): self
{
$this->coach = $coach;
return $this;
}
public function getClub(): ?Club
{
return $this->club;
}
public function setClub(?Club $club): self
{
$this->club = $club;
return $this;
}
public function getOperator(): ?Operator
{
return $this->operator;
}
public function setOperator(?Operator $operator): self
{
$this->operator = $operator;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getRequestDate(): ?\DateTimeInterface
{
return $this->requestDate;
}
public function setRequestDate(\DateTimeInterface $requestDate): self
{
$this->requestDate = $requestDate;
return $this;
}
public function getAcceptedDate(): ?\DateTimeInterface
{
return $this->acceptedDate;
}
public function setAcceptedDate(?\DateTimeInterface $acceptedDate): self
{
$this->acceptedDate = $acceptedDate;
return $this;
}
public function getRequestedBy(): ?User
{
return $this->requestedBy;
}
public function setRequestedBy(?User $requestedBy): self
{
$this->requestedBy = $requestedBy;
return $this;
}
}