src/Entity/Provider.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProviderRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassProviderRepository::class)]
  10. #[ORM\InheritanceType('JOINED')]
  11. #[ORM\DiscriminatorColumn(name"dtype"type"string")]
  12. #[ORM\DiscriminatorMap(['hotel' => Hotel::class , 'hotelchain' => HotelChain::class, 'other' => OtherProvider::class])]
  13. #[UniqueEntity(['name'])]
  14. class Provider
  15. {
  16.     //   use TimestampableEntity;
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column(type'integer')]
  20.     private $id;
  21.     #[ORM\Column(type'string'length128)]
  22.     #[Assert\NotBlank(message'This value should not be blank')]
  23.     #[Assert\Length(max128)]
  24.     #[Assert\Regex(
  25.         pattern'/^[\p{L}\p{M}\s\'\-_&]+$/u',
  26.     )]
  27.     private ?string $name;
  28.     #[ORM\Column(type'string'length255nullabletrue)]
  29.     private ?string $address;
  30.     #[ORM\Column(type'decimal'precision16scale12nullabletrue)]
  31.     private ?string $longitude;
  32.     #[ORM\Column(type'decimal'precision16scale12nullabletrue)]
  33.     private ?string $latitude;
  34.     #[ORM\Column(type'string'length255nullabletrue)]
  35.     private ?string $email;
  36.     #[ORM\Column(type'string'length255nullabletrue)]
  37.     private ?string $website;
  38.     #[ORM\Column(type'string'length32nullabletrue)]
  39.     private ?string $phone;
  40.     #[ORM\Column(type'string'length32nullabletrue)]
  41.     private ?string $fax;
  42.     #[ORM\Column(type'string'length64nullabletrue)]
  43.     private ?string $rib;
  44.     #[ORM\Column(type'boolean')]
  45.     private bool $active;
  46.     #[ORM\ManyToOne(targetEntityCity::class)]
  47.     private ?City $city;
  48.     #[ORM\OneToMany(mappedBy'provider'targetEntityFileData::class, cascade: ['persist'])]
  49.     private $images;
  50.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  51.     private ?FileData $logo null;
  52.     #[ORM\Column(length3)]
  53.     private ?string $currency null;
  54.     public function __construct()
  55.     {
  56.         $this->images = new ArrayCollection();
  57.     }
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getName(): ?string
  63.     {
  64.         return $this->name;
  65.     }
  66.     public function setName(?string $name): self
  67.     {
  68.         $this->name $name;
  69.         return $this;
  70.     }
  71.     public function getAddress(): ?string
  72.     {
  73.         return $this->address;
  74.     }
  75.     public function setAddress(?string $address): self
  76.     {
  77.         $this->address $address;
  78.         return $this;
  79.     }
  80.     public function getLongitude(): ?string
  81.     {
  82.         return $this->longitude;
  83.     }
  84.     public function setLongitude(?string $longitude): self
  85.     {
  86.         $this->longitude $longitude;
  87.         return $this;
  88.     }
  89.     public function getLatitude(): ?string
  90.     {
  91.         return $this->latitude;
  92.     }
  93.     public function setLatitude(?string $latitude): self
  94.     {
  95.         $this->latitude $latitude;
  96.         return $this;
  97.     }
  98.     public function getEmail(): ?string
  99.     {
  100.         return $this->email;
  101.     }
  102.     public function setEmail(?string $email): self
  103.     {
  104.         $this->email $email;
  105.         return $this;
  106.     }
  107.     public function getWebsite(): ?string
  108.     {
  109.         return $this->website;
  110.     }
  111.     public function setWebsite(?string $website): self
  112.     {
  113.         $this->website $website;
  114.         return $this;
  115.     }
  116.     public function getPhone(): ?string
  117.     {
  118.         return $this->phone;
  119.     }
  120.     public function setPhone(?string $phone): self
  121.     {
  122.         $this->phone $phone;
  123.         return $this;
  124.     }
  125.     public function getFax(): ?string
  126.     {
  127.         return $this->fax;
  128.     }
  129.     public function setFax(?string $fax): self
  130.     {
  131.         $this->fax $fax;
  132.         return $this;
  133.     }
  134.     public function getRib(): ?string
  135.     {
  136.         return $this->rib;
  137.     }
  138.     public function setRib(?string $rib): self
  139.     {
  140.         $this->rib $rib;
  141.         return $this;
  142.     }
  143.     public function isActive(): ?bool
  144.     {
  145.         return $this->active;
  146.     }
  147.     public function setActive(bool $active): self
  148.     {
  149.         $this->active $active;
  150.         return $this;
  151.     }
  152.     public function getCity(): ?City
  153.     {
  154.         return $this->city;
  155.     }
  156.     public function setCity(?City $city): self
  157.     {
  158.         $this->city $city;
  159.         return $this;
  160.     }
  161.     public function __toString(): string
  162.     {
  163.         return $this->name;
  164.     }
  165.     /**
  166.      * @return Collection<int, FileData>
  167.      */
  168.     public function getImages(): Collection
  169.     {
  170.         return $this->images;
  171.     }
  172.     public function addImage(FileData $image): self
  173.     {
  174.         if (!$this->images->contains($image)) {
  175.             $this->images[] = $image;
  176.             $image->setProvider($this);
  177.         }
  178.         return $this;
  179.     }
  180.     public function removeImage(FileData $image): self
  181.     {
  182.         if ($this->images->removeElement($image)) {
  183.             // set the owning side to null (unless already changed)
  184.             if ($image->getProvider() === $this) {
  185.                 $image->setProvider(null);
  186.             }
  187.         }
  188.         return $this;
  189.     }
  190.     public function getPrimaryImageUrl(): ?string
  191.     {
  192.         foreach ($this->images as $image){
  193.             if($image->getDisplayOrder()==1){
  194.                 return $image->getUrl();
  195.             }
  196.         }
  197.         return null;
  198.     }
  199.     public function getLogo(): ?FileData
  200.     {
  201.         return $this->logo;
  202.     }
  203.     public function setLogo(?FileData $logo): self
  204.     {
  205.         $this->logo $logo;
  206.         return $this;
  207.     }
  208.     public function getCurrency(): ?string
  209.     {
  210.         return $this->currency;
  211.     }
  212.     public function setCurrency(?string $currency): self
  213.     {
  214.         $this->currency $currency;
  215.         return $this;
  216.     }
  217. }