src/Entity/ClubPresentation.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\ClubPresentationRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassClubPresentationRepository::class)]
  10. #[ApiResource]
  11. class ClubPresentation
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\ManyToOne(inversedBy'clubPresentations')]
  18.     #[ORM\JoinColumn(nullablefalseonDelete"CASCADE")]
  19.     private ?club $club null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $link null;
  22.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  23.     private ?string $message null;
  24.     #[ORM\Column(length255nullabletrue)]
  25.     private ?string $title null;
  26.     #[ORM\OneToMany(mappedBy'clubPresentation'targetEntityPhoto::class, cascade: ["persist"])]
  27.     private Collection $photos;
  28.     public function __construct()
  29.     {
  30.         $this->photos = new ArrayCollection();
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getImageUrl(): string
  37.     {
  38.         $mainPhoto $this->getMainPhoto();
  39.         if ($mainPhoto) {
  40.             return $mainPhoto->getImageLarge()->getUrl();
  41.         }
  42.         return 'https://localbeez.ri7.fr/assets/img/image_placeholder.jpg';
  43.     }
  44.     public function getMainPhoto()
  45.     {
  46.         foreach ($this->photos as $p) {
  47.             if ($p->isMain()) {
  48.                 return $p;
  49.             }
  50.         }
  51.         if (sizeof($this->photos) > 0) {
  52.             return $this->photos[0];
  53.         }
  54.         return false;
  55.     }
  56.     public function getSmallImageUrl(): string
  57.     {
  58.         $mainPhoto $this->getMainPhoto();
  59.         if ($mainPhoto) {
  60.             return $mainPhoto->getImageSmall()->getUrl();
  61.         }
  62.         return 'https://localbeez.ri7.fr/assets/img/image_placeholder.jpg';
  63.     }
  64.     public function getMediumImageUrl(): string
  65.     {
  66.         $mainPhoto $this->getMainPhoto();
  67.         if ($mainPhoto) {
  68.             return $mainPhoto->getImageMedium()->getUrl();
  69.         }
  70.         return 'https://localbeez.ri7.fr/assets/img/image_placeholder.jpg';
  71.     }
  72.     public function getClub(): ?club
  73.     {
  74.         return $this->club;
  75.     }
  76.     public function setClub(?club $club): static
  77.     {
  78.         $this->club $club;
  79.         return $this;
  80.     }
  81.     public function getLink(): ?string
  82.     {
  83.         return $this->link;
  84.     }
  85.     public function setLink(?string $link): static
  86.     {
  87.         $this->link $link;
  88.         return $this;
  89.     }
  90.     public function getMessage(): ?string
  91.     {
  92.         return $this->message;
  93.     }
  94.     public function setMessage(?string $message): static
  95.     {
  96.         $this->message $message;
  97.         return $this;
  98.     }
  99.     public function getTitle(): ?string
  100.     {
  101.         return $this->title;
  102.     }
  103.     public function setTitle(?string $title): static
  104.     {
  105.         $this->title $title;
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return Collection<int, Photo>
  110.      */
  111.     public function getPhotos(): Collection
  112.     {
  113.         return $this->photos;
  114.     }
  115.     public function addPhoto(Photo $photo): static
  116.     {
  117.         if (!$this->photos->contains($photo)) {
  118.             $this->photos->add($photo);
  119.             $photo->setClubPresentation($this);
  120.         }
  121.         return $this;
  122.     }
  123.     public function removePhoto(Photo $photo): static
  124.     {
  125.         if ($this->photos->removeElement($photo)) {
  126.             // set the owning side to null (unless already changed)
  127.             if ($photo->getClubPresentation() === $this) {
  128.                 $photo->setClubPresentation(null);
  129.             }
  130.         }
  131.         return $this;
  132.     }
  133. }