src/Entity/Dealer.php line 28

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Tests\Fixtures\Metadata\Get;
  6. use App\Entity\Enum\ImportVehicleType;
  7. use App\Repository\DealerRepository;
  8. use App\Repository\VehicleRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\DBAL\Types\Types;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\String\Slugger\AsciiSlugger;
  14. use Symfony\Component\Validator\Constraints\Email;
  15. use Symfony\Component\Validator\Constraints\NotBlank;
  16. #[ApiResource(
  17.     operations: [
  18.         new GetCollection(),
  19.         new Get(),
  20.     ],
  21. )]
  22. #[ORM\Entity(repositoryClassDealerRepository::class)]
  23. class Dealer
  24. {
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue]
  27.     #[ORM\Column]
  28.     private ?int $id null;
  29.     #[NotBlank]
  30.     #[ORM\Column(length255)]
  31.     private ?string $name null;
  32.     #[ORM\Column(options: ['default' => false])]
  33.     private bool $authSeller false;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     private ?string $city null;
  36.     #[ORM\Column(length255nullabletrue)]
  37.     private ?string $street null;
  38.     #[ORM\Column]
  39.     private ?bool $checkVin null;
  40.     #[ORM\Column(nullabletrue)]
  41.     private ?bool $visible null;
  42.     #[ORM\Column(nullabletrue)]
  43.     private ?bool $basicAdvertising null;
  44.     #[Email]
  45.     #[ORM\Column(length255nullabletrue)]
  46.     private ?string $email null;
  47.     #[ORM\Column(length255nullabletrue)]
  48.     private ?string $www null;
  49.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  50.     private ?string $description null;
  51.     #[ORM\Column(nullabletrue)]
  52.     private ?float $lng null;
  53.     #[ORM\Column(nullabletrue)]
  54.     private ?float $lat null;
  55.     #[ORM\Column(nullabletrue)]
  56.     private ?int $rank null;
  57.     #[ORM\OrderBy(['main' => 'DESC'])]
  58.     #[ORM\OneToMany(mappedBy'dealer'targetEntityDealerImage::class, cascade: ['persist''remove'])]
  59.     private Collection $dealerImages;
  60.     #[ORM\OneToMany(mappedBy'dealer'targetEntityDealerPhone::class, cascade: ['persist''remove'])]
  61.     private Collection $dealerPhones;
  62.     #[ORM\OneToMany(mappedBy'dealer'targetEntityDealerOpenHour::class, cascade: ['persist''remove'])]
  63.     private Collection $dealerOpenHours;
  64.     #[ORM\Column(nullabletrue)]
  65.     private ?string $logo null;
  66.     #[ORM\Column(nullabletrue)]
  67.     private ?int $importId null;
  68.     #[ORM\ManyToOne(inversedBy'dealers')]
  69.     private ?District $district null;
  70.     #[ORM\Column(length255nullabletrueenumTypeImportVehicleType::class)]
  71.     private ?ImportVehicleType $nameImportVehicle null;
  72.     #[ORM\Column(length255nullabletrue)]
  73.     private ?string $idImportVehicle null;
  74.     #[ORM\OneToMany(mappedBy'dealer'targetEntityDealerImport::class)]
  75.     private Collection $dealerImports;
  76.     #[ORM\OneToMany(mappedBy'dealer'targetEntityVehicle::class)]
  77.     private Collection $vehicles;
  78.     #[ORM\Column(length255)]
  79.     private ?string $url null;
  80.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  81.     private ?string $openingHoursNote null;
  82.     public function __construct()
  83.     {
  84.         $this->dealerImages = new ArrayCollection();
  85.         $this->dealerPhones = new ArrayCollection();
  86.         $this->dealerOpenHours = new ArrayCollection();
  87.         $this->dealerImports = new ArrayCollection();
  88.         $this->vehicles = new ArrayCollection();
  89.     }
  90.     public function getId(): ?int
  91.     {
  92.         return $this->id;
  93.     }
  94.     /**
  95.      * @return string|null
  96.      */
  97.     public function getLogo(): ?string
  98.     {
  99.         return $this->logo;
  100.     }
  101.     /**
  102.      * @param string|null $logo
  103.      */
  104.     public function setLogo(?string $logo): void
  105.     {
  106.         $this->logo $logo;
  107.     }
  108.     public function getName(): ?string
  109.     {
  110.         return $this->name;
  111.     }
  112.     public function setName(string $name): self
  113.     {
  114.         $this->name $name;
  115.         return $this;
  116.     }
  117.     public function isAuthSeller(): bool
  118.     {
  119.         return $this->authSeller;
  120.     }
  121.     public function setAuthSeller(bool $authSeller): self
  122.     {
  123.         $this->authSeller $authSeller;
  124.         return $this;
  125.     }
  126.     public function getCity(): ?string
  127.     {
  128.         return $this->city;
  129.     }
  130.     public function setCity(string $city): self
  131.     {
  132.         $this->city $city;
  133.         return $this;
  134.     }
  135.     public function isCheckVin(): ?bool
  136.     {
  137.         return $this->checkVin;
  138.     }
  139.     public function setCheckVin(bool $checkVin): self
  140.     {
  141.         $this->checkVin $checkVin;
  142.         return $this;
  143.     }
  144.     public function isVisible(): ?bool
  145.     {
  146.         return $this->visible;
  147.     }
  148.     public function setVisible(bool $visible): self
  149.     {
  150.         $this->visible $visible;
  151.         return $this;
  152.     }
  153.     public function isBasicAdvertising(): ?bool
  154.     {
  155.         return $this->basicAdvertising;
  156.     }
  157.     public function setBasicAdvertising(?bool $basicAdvertising): self
  158.     {
  159.         $this->basicAdvertising $basicAdvertising;
  160.         return $this;
  161.     }
  162.     public function getEmail(): ?string
  163.     {
  164.         return $this->email;
  165.     }
  166.     public function setEmail(string $email): self
  167.     {
  168.         $this->email $email;
  169.         return $this;
  170.     }
  171.     public function getWww(): ?string
  172.     {
  173.         return $this->www;
  174.     }
  175.     public function setWww(?string $www): self
  176.     {
  177.         $this->www $www;
  178.         return $this;
  179.     }
  180.     public function getDescription(): ?string
  181.     {
  182.         return $this->description;
  183.     }
  184.     public function setDescription(?string $description): self
  185.     {
  186.         $this->description $description;
  187.         return $this;
  188.     }
  189.     public function getLng(): ?float
  190.     {
  191.         return $this->lng;
  192.     }
  193.     public function setLng(float $lng): self
  194.     {
  195.         $this->lng $lng;
  196.         return $this;
  197.     }
  198.     public function getLat(): ?float
  199.     {
  200.         return $this->lat;
  201.     }
  202.     public function setLat(float $lat): self
  203.     {
  204.         $this->lat $lat;
  205.         return $this;
  206.     }
  207.     public function getRank(): ?int
  208.     {
  209.         return $this->rank;
  210.     }
  211.     public function setRank(?int $rank): self
  212.     {
  213.         $this->rank $rank;
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return Collection<int, DealerImage>
  218.      */
  219.     public function getDealerImages(): Collection
  220.     {
  221.         return $this->dealerImages;
  222.     }
  223.     public function addDealerImage(DealerImage $dealerImage): self
  224.     {
  225.         if (!$this->dealerImages->contains($dealerImage)) {
  226.             $this->dealerImages->add($dealerImage);
  227.             $dealerImage->setDealer($this);
  228.         }
  229.         return $this;
  230.     }
  231.     public function removeDealerImage(DealerImage $dealerImage): self
  232.     {
  233.         if ($this->dealerImages->removeElement($dealerImage)) {
  234.             // set the owning side to null (unless already changed)
  235.             if ($dealerImage->getDealer() === $this) {
  236.                 $dealerImage->setDealer(null);
  237.             }
  238.         }
  239.         return $this;
  240.     }
  241.     /**
  242.      * @return Collection<int, DealerPhone>
  243.      */
  244.     public function getDealerPhones(): Collection
  245.     {
  246.         return $this->dealerPhones;
  247.     }
  248.     public function addDealerPhone(DealerPhone $dealerPhone): self
  249.     {
  250.         if (!$this->dealerPhones->contains($dealerPhone)) {
  251.             $this->dealerPhones->add($dealerPhone);
  252.             $dealerPhone->setDealer($this);
  253.         }
  254.         return $this;
  255.     }
  256.     public function removeDealerPhone(DealerPhone $dealerPhone): self
  257.     {
  258.         if ($this->dealerPhones->removeElement($dealerPhone)) {
  259.             // set the owning side to null (unless already changed)
  260.             if ($dealerPhone->getDealer() === $this) {
  261.                 $dealerPhone->setDealer(null);
  262.             }
  263.         }
  264.         return $this;
  265.     }
  266.     /**
  267.      * @return Collection<int, DealerOpenHour>
  268.      */
  269.     public function getDealerOpenHours(): Collection
  270.     {
  271.         return $this->dealerOpenHours;
  272.     }
  273.     public function addDealerOpenHour(DealerOpenHour $dealerOpenHour): self
  274.     {
  275.         if (!$this->dealerOpenHours->contains($dealerOpenHour)) {
  276.             $this->dealerOpenHours->add($dealerOpenHour);
  277.             $dealerOpenHour->setDealer($this);
  278.         }
  279.         return $this;
  280.     }
  281.     public function removeDealerOpenHour(DealerOpenHour $dealerOpenHour): self
  282.     {
  283.         if ($this->dealerOpenHours->removeElement($dealerOpenHour)) {
  284.             // set the owning side to null (unless already changed)
  285.             if ($dealerOpenHour->getDealer() === $this) {
  286.                 $dealerOpenHour->setDealer(null);
  287.             }
  288.         }
  289.         return $this;
  290.     }
  291.     public function getImportId(): ?int
  292.     {
  293.         return $this->importId;
  294.     }
  295.     public function setImportId(?int $importId): self
  296.     {
  297.         $this->importId $importId;
  298.         return $this;
  299.     }
  300.     public function getStreet(): ?string
  301.     {
  302.         return $this->street;
  303.     }
  304.     public function setStreet(string $street): self
  305.     {
  306.         $this->street $street;
  307.         return $this;
  308.     }
  309.     public function getDistrict(): ?District
  310.     {
  311.         return $this->district;
  312.     }
  313.     public function setDistrict(?District $district): self
  314.     {
  315.         $this->district $district;
  316.         return $this;
  317.     }
  318.     public function getNameImportVehicle(): ?ImportVehicleType
  319.     {
  320.         return $this->nameImportVehicle;
  321.     }
  322.     public function setNameImportVehicle(?ImportVehicleType $nameImportVehicle): self
  323.     {
  324.         $this->nameImportVehicle $nameImportVehicle;
  325.         return $this;
  326.     }
  327.     public function getIdImportVehicle(): ?string
  328.     {
  329.         return $this->idImportVehicle;
  330.     }
  331.     public function setIdImportVehicle(?string $idImportVehicle): self
  332.     {
  333.         $this->idImportVehicle $idImportVehicle;
  334.         return $this;
  335.     }
  336.     /**
  337.      * @return Collection<int, DealerImport>
  338.      */
  339.     public function getDealerImports(): Collection
  340.     {
  341.         return $this->dealerImports;
  342.     }
  343.     public function addDealerImport(DealerImport $dealerImport): self
  344.     {
  345.         if (!$this->dealerImports->contains($dealerImport)) {
  346.             $this->dealerImports->add($dealerImport);
  347.             $dealerImport->setDealer($this);
  348.         }
  349.         return $this;
  350.     }
  351.     public function removeDealerImport(DealerImport $dealerImport): self
  352.     {
  353.         if ($this->dealerImports->removeElement($dealerImport)) {
  354.             // set the owning side to null (unless already changed)
  355.             if ($dealerImport->getDealer() === $this) {
  356.                 $dealerImport->setDealer(null);
  357.             }
  358.         }
  359.         return $this;
  360.     }
  361.     /**
  362.      * @return Collection<int, Vehicle>
  363.      */
  364.     public function getVehicles(): Collection
  365.     {
  366.         return $this->vehicles;
  367.     }
  368.     public function addVehicle(Vehicle $vehicle): self
  369.     {
  370.         if (!$this->vehicles->contains($vehicle)) {
  371.             $this->vehicles->add($vehicle);
  372.             $vehicle->setDealer($this);
  373.         }
  374.         return $this;
  375.     }
  376.     public function removeVehicle(Vehicle $vehicle): self
  377.     {
  378.         if ($this->vehicles->removeElement($vehicle)) {
  379.             // set the owning side to null (unless already changed)
  380.             if ($vehicle->getDealer() === $this) {
  381.                 $vehicle->setDealer(null);
  382.             }
  383.         }
  384.         return $this;
  385.     }
  386.     public function getUrl(): ?string
  387.     {
  388.         return $this->url;
  389.     }
  390.     public function setUrl(string $url): self
  391.     {
  392.         if($url) {
  393.             $slugger = new AsciiSlugger('cs');
  394.             $slug =   $slugger->slug($url'-')->lower();
  395.             $this->url $slug->toString();
  396.         } else {
  397.             $this->url null;
  398.         }
  399.         return $this;
  400.     }
  401.     public function getOpeningHoursNote(): ?string
  402.     {
  403.         return $this->openingHoursNote;
  404.     }
  405.     public function setOpeningHoursNote(?string $openingHoursNote): self
  406.     {
  407.         $this->openingHoursNote $openingHoursNote;
  408.         return $this;
  409.     }
  410. }