src/Entity/Provider.php line 16

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