src/Entity/Car.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CarRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. //use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10.  * @ORM\Entity(repositoryClass=CarRepository::class)
  11.  * @ORM\HasLifecycleCallbacks()
  12.  */
  13. class Car
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $name;
  25.     /**
  26.      * @ORM\Column(type="integer")
  27.      */
  28.     private $year;
  29.     /**
  30.      * @ORM\Column(type="text", nullable=true)
  31.      */
  32.     private $description;
  33.     /**
  34.      * @ORM\Column(type="datetime")
  35.      */
  36.     private $createdAt;
  37.     /**
  38.      * @ORM\Column(type="datetime", nullable=true)
  39.      */
  40.     private $updatedAt;
  41.     /**
  42.      * @ORM\Column(type="integer", nullable=true)
  43.      */
  44.     private $km;
  45.     /**
  46.      * @ORM\Column(type="string", length=255)
  47.      */
  48.     private $patent;
  49.     /**
  50.      * @ORM\Column(type="integer", nullable=true)
  51.      */
  52.     private $pricePurchase;
  53.     /**
  54.      * @ORM\Column(type="integer", nullable=true)
  55.      */
  56.     private $priceSale;
  57.     /**
  58.      * @ORM\ManyToOne(targetEntity=Brand::class, inversedBy="carId")
  59.      * @ORM\JoinColumn(nullable=false)
  60.      */
  61.     private $brand;
  62.     /**
  63.      * @ORM\Column(type="string", length=5, nullable=true)
  64.      */
  65.     private $priceCurrencyPurchase;
  66.     /**
  67.      * @ORM\Column(type="string", length=5, nullable=true)
  68.      */
  69.     private $priceCurrencySale;
  70.     //* @ORM\OneToMany(targetEntity=CarImages::class, mappedBy="car", cascade={"persist", "remove"}, orphanRemoval=true)
  71.     /**
  72.      * @ORM\OneToMany(targetEntity=CarImages::class, mappedBy="car", cascade={"persist", "remove"}, orphanRemoval=true)
  73.      * @ORM\OrderBy({"position" = "ASC"})
  74.      */
  75.     private $imageId;
  76.     /**
  77.      * @ORM\Column(type="json", nullable=true)
  78.      */
  79.     private $features = [];
  80.     /**
  81.      * @ORM\OneToMany(targetEntity=CarBuy::class, mappedBy="car")
  82.      */
  83.     private $carBuyId;
  84.     /**
  85.      * @ORM\OneToMany(targetEntity=CarSale::class, mappedBy="carSale")
  86.      */
  87.     private $carSaleId;
  88.     /**
  89.      * @ORM\OneToMany(targetEntity=CarSale::class, mappedBy="carSalePayment")
  90.      */
  91.     private $carSalePaymentId;
  92.     /**
  93.      * @ORM\Column(type="string", length=255, nullable=true)
  94.      */
  95.     private $status;
  96.     /**
  97.      * @ORM\Column(type="string", length=50, nullable=true)
  98.      */
  99.     private $engineNumber;
  100.     /**
  101.      * @ORM\Column(type="string", length=50, nullable=true)
  102.      */
  103.     private $chassisNumber;
  104.     /**
  105.      * @ORM\Column(type="string", length=50, nullable=true)
  106.      */
  107.     private $type;
  108.     /**
  109.      * @ORM\Column(type="string", length=50, nullable=true)
  110.      */
  111.     private $settlement;
  112.     /**
  113.      * @ORM\Column(type="integer", nullable=true)
  114.      */
  115.     private $position;
  116.     /**
  117.      * @ORM\OneToMany(targetEntity=CarBuy::class, mappedBy="carSwap")
  118.      */
  119.     private $carSwapId;
  120.     /**
  121.      * @ORM\OneToMany(targetEntity=CarResale::class, mappedBy="car")
  122.      */
  123.     private $carResales;
  124.     /**
  125.      * @ORM\ManyToOne(targetEntity=Branches::class, inversedBy="carId")
  126.      * @ORM\JoinColumn(nullable=true)
  127.      */
  128.     private $branches;
  129.     /**
  130.      * @ORM\Column(type="text", nullable=true)
  131.      */
  132.     private $featuresInfoauto;
  133.     /**
  134.      * @ORM\Column(type="string", length=255, nullable=true)
  135.      */
  136.     private $color;
  137.     /**
  138.      * @ORM\ManyToOne(targetEntity=Destinations::class, inversedBy="cars")
  139.      */
  140.     private $destination;
  141.     /**
  142.      * @ORM\Column(type="boolean", nullable=true)
  143.      */
  144.     private $isOpportunity;
  145.     /**
  146.      * @ORM\Column(type="boolean", nullable=true)
  147.      */
  148.     private $is0km;
  149.     /**
  150.      * @ORM\Column(type="boolean", nullable=true)
  151.      */
  152.     private $isImmediateDelivery;
  153.     public function __construct()
  154.     {
  155.         $this->imageId = new ArrayCollection();
  156.         $this->carBuyId = new ArrayCollection();
  157.         $this->carSaleId = new ArrayCollection();
  158.         $this->carSalePaymentId = new ArrayCollection();
  159.         $this->carSwapId = new ArrayCollection();
  160.         $this->carResales = new ArrayCollection();
  161.     }
  162.     public function getId(): ?int
  163.     {
  164.         return $this->id;
  165.     }
  166.     public function getName(): ?string
  167.     {
  168.         return $this->name;
  169.     }
  170.     public function setName(string $name): self
  171.     {
  172.         $this->name $name;
  173.         return $this;
  174.     }
  175.     public function getYear(): ?int
  176.     {
  177.         return $this->year;
  178.     }
  179.     public function setYear(int $year): self
  180.     {
  181.         $this->year $year;
  182.         return $this;
  183.     }
  184.     public function getDescription(): ?string
  185.     {
  186.         return $this->description;
  187.     }
  188.     public function setDescription(?string $description): self
  189.     {
  190.         $this->description $description;
  191.         return $this;
  192.     }
  193.     public function getCreatedAt(): ?\DateTimeInterface
  194.     {
  195.         return $this->createdAt;
  196.     }
  197.     /**
  198.      * @ORM\PrePersist
  199.      */
  200.     public function setCreatedAt(): self
  201.     {
  202.         $this->createdAt = new \DateTime();
  203.         return $this;
  204.     }
  205.     public function getUpdatedAt(): ?\DateTimeInterface
  206.     {
  207.         return $this->updatedAt;
  208.     }
  209.     /**
  210.      * @ORM\PreUpdate
  211.      */
  212.     public function setUpdatedAt(): self
  213.     {
  214.         $this->updatedAt = new \DateTime();
  215.         return $this;
  216.     }
  217.     public function getKm(): ?int
  218.     {
  219.         return $this->km;
  220.     }
  221.     public function setKm(?int $km): self
  222.     {
  223.         $this->km $km;
  224.         return $this;
  225.     }
  226.     public function getPatent(): ?string
  227.     {
  228.         return $this->patent;
  229.     }
  230.     public function setPatent(string $patent): self
  231.     {
  232.         $this->patent $patent;
  233.         return $this;
  234.     }
  235.     public function getPricePurchase(): ?int
  236.     {
  237.         return $this->pricePurchase;
  238.     }
  239.     public function setPricePurchase($pricePurchase): self
  240.     {
  241.         $this->pricePurchase str_replace('.'''$pricePurchase);
  242.         return $this;
  243.     }
  244.     public function getPriceSale(): ?int
  245.     {
  246.         return $this->priceSale;
  247.     }
  248.     public function setPriceSale($priceSale): self
  249.     {
  250.         $this->priceSale str_replace('.'''$priceSale);
  251.         return $this;
  252.     }
  253.     public function getBrand(): ?Brand
  254.     {
  255.         return $this->brand;
  256.     }
  257.     public function setBrand(?Brand $brand): self
  258.     {
  259.         $this->brand $brand;
  260.         return $this;
  261.     }
  262.     public function getPriceCurrency(): ?string
  263.     {
  264.         return $this->priceCurrency;
  265.     }
  266.     public function setPriceCurrency(string $priceCurrency): self
  267.     {
  268.         $this->priceCurrency $priceCurrency;
  269.         return $this;
  270.     }
  271.     public function getPriceCurrencyPurchase(): ?string
  272.     {
  273.         return $this->priceCurrencyPurchase;
  274.     }
  275.     public function setPriceCurrencyPurchase(string $priceCurrencyPurchase): self
  276.     {
  277.         $this->priceCurrencyPurchase $priceCurrencyPurchase;
  278.         return $this;
  279.     }
  280.     public function getPriceCurrencySale(): ?string
  281.     {
  282.         return $this->priceCurrencySale;
  283.     }
  284.     public function setPriceCurrencySale(string $priceCurrencySale): self
  285.     {
  286.         $this->priceCurrencySale $priceCurrencySale;
  287.         return $this;
  288.     }
  289.     /**
  290.      * @return Collection|CarImages[]
  291.      */
  292.     public function getImageId(): Collection
  293.     {
  294.         return $this->imageId;
  295.     }
  296.     public function addImageId(CarImages $img): self
  297.     {
  298.         if (!$this->imageId->contains($img)) {
  299.             $img->setCar($this);
  300.             if ($img->getPosition() === 0) {
  301.                 $img->setPosition($this->imageId->count());
  302.             }
  303.             $this->imageId->add($img);
  304.         }
  305.         return $this;
  306.     }
  307.     public function removeImageId(CarImages $imageId): self
  308.     {
  309.         if ($this->imageId->removeElement($imageId)) {
  310.             // set the owning side to null (unless already changed)
  311.             if ($imageId->getCar() === $this) {
  312.                 $imageId->setCar(null);
  313.             }
  314.         }
  315.         return $this;
  316.     }
  317.     public function getFeatures(): ?array
  318.     {
  319.         if ($this->features) {
  320.             return $this->features;
  321.         } else {
  322.             $empty[] = null;
  323.             return $empty;
  324.         }
  325.     }
  326.     public function setFeatures(?array $features): self
  327.     {
  328.         $this->features $features;
  329.         return $this;
  330.     }
  331.     /**
  332.      * @return Collection|CarBuy[]
  333.      */
  334.     public function getCarBuyId(): Collection
  335.     {
  336.         return $this->carBuyId;
  337.     }
  338.     public function addCarBuyId(CarBuy $carBuyId): self
  339.     {
  340.         if (!$this->carBuyId->contains($carBuyId)) {
  341.             $this->carBuyId[] = $carBuyId;
  342.             $carBuyId->setCar($this);
  343.         }
  344.         return $this;
  345.     }
  346.     public function removeCarBuyId(CarBuy $carBuyId): self
  347.     {
  348.         if ($this->carBuyId->removeElement($carBuyId)) {
  349.             // set the owning side to null (unless already changed)
  350.             if ($carBuyId->getCar() === $this) {
  351.                 $carBuyId->setCar(null);
  352.             }
  353.         }
  354.         return $this;
  355.     }
  356.     public function __toString()
  357.     {
  358.         return $this->name.' ('.$this->patent.')';
  359.     }
  360.     /**
  361.      * @return Collection|CarSale[]
  362.      */
  363.     public function getCarSaleId(): Collection
  364.     {
  365.         return $this->carSaleId;
  366.     }
  367.     public function addCarSaleId(CarSale $carSaleId): self
  368.     {
  369.         if (!$this->carSaleId->contains($carSaleId)) {
  370.             $this->carSaleId[] = $carSaleId;
  371.             $carSaleId->setCarSale($this);
  372.         }
  373.         return $this;
  374.     }
  375.     public function removeCarSaleId(CarSale $carSaleId): self
  376.     {
  377.         if ($this->carSaleId->removeElement($carSaleId)) {
  378.             // set the owning side to null (unless already changed)
  379.             if ($carSaleId->getCarSale() === $this) {
  380.                 $carSaleId->setCarSale(null);
  381.             }
  382.         }
  383.         return $this;
  384.     }
  385.     /**
  386.      * @return Collection|CarSale[]
  387.      */
  388.     public function getCarSalePaymentId(): Collection
  389.     {
  390.         return $this->carSalePaymentId;
  391.     }
  392.     public function addCarSalePaymentId(CarSale $carSalePaymentId): self
  393.     {
  394.         if (!$this->carSalePaymentId->contains($carSalePaymentId)) {
  395.             $this->carSalePaymentId[] = $carSalePaymentId;
  396.             $carSalePaymentId->setCarSalePayment($this);
  397.         }
  398.         return $this;
  399.     }
  400.     public function removeCarSalePaymentId(CarSale $carSalePaymentId): self
  401.     {
  402.         if ($this->carSalePaymentId->removeElement($carSalePaymentId)) {
  403.             // set the owning side to null (unless already changed)
  404.             if ($carSalePaymentId->getCarSalePayment() === $this) {
  405.                 $carSalePaymentId->setCarSalePayment(null);
  406.             }
  407.         }
  408.         return $this;
  409.     }
  410.     public function getStatus(): ?string
  411.     {
  412.         return $this->status;
  413.     }
  414.     public function setStatus(?string $status): self
  415.     {
  416.         $this->status $status;
  417.         return $this;
  418.     }
  419.     /**
  420.      * @return Collection|CarBuy[]
  421.      */
  422.     public function getCarSwapId(): Collection
  423.     {
  424.         return $this->carSwapId;
  425.     }
  426.     public function addCarSwapId(CarBuy $carSwapId): self
  427.     {
  428.         if (!$this->carSwapId->contains($carSwapId)) {
  429.             $this->carSwapId[] = $carSwapId;
  430.             $carSwapId->setCarSwap($this);
  431.         }
  432.         return $this;
  433.     }
  434.     public function removeCarSwapId(CarBuy $carSwapId): self
  435.     {
  436.         if ($this->carSwapId->removeElement($carSwapId)) {
  437.             // set the owning side to null (unless already changed)
  438.             if ($carSwapId->getCarSwap() === $this) {
  439.                 $carSwapId->setCarSwap(null);
  440.             }
  441.         }
  442.         return $this;
  443.     }
  444.     public function getEngineNumber(): ?string
  445.     {
  446.         return $this->engineNumber;
  447.     }
  448.     public function setEngineNumber(?string $engineNumber): self
  449.     {
  450.         $this->engineNumber $engineNumber;
  451.         return $this;
  452.     }
  453.     public function getChassisNumber(): ?string
  454.     {
  455.         return $this->chassisNumber;
  456.     }
  457.     public function setChassisNumber(?string $chassisNumber): self
  458.     {
  459.         $this->chassisNumber $chassisNumber;
  460.         return $this;
  461.     }
  462.     public function getType(): ?string
  463.     {
  464.         return $this->type;
  465.     }
  466.     public function setType(?string $type): self
  467.     {
  468.         $this->type $type;
  469.         return $this;
  470.     }
  471.     public function getSettlement(): ?string
  472.     {
  473.         return $this->settlement;
  474.     }
  475.     public function setSettlement(?string $settlement): self
  476.     {
  477.         $this->settlement $settlement;
  478.         return $this;
  479.     }
  480.     public function getPosition(): ?int
  481.     {
  482.         return $this->position;
  483.     }
  484.     public function setPosition(int $position): self
  485.     {
  486.         $this->position $position;
  487.         return $this;
  488.     }
  489.     /**
  490.      * @return Collection<int, CarResale>
  491.      */
  492.     public function getCarResales(): Collection
  493.     {
  494.         return $this->carResales;
  495.     }
  496.     public function addCarResale(CarResale $carResale): self
  497.     {
  498.         if (!$this->carResales->contains($carResale)) {
  499.             $this->carResales[] = $carResale;
  500.             $carResale->setCar($this);
  501.         }
  502.         return $this;
  503.     }
  504.     public function removeCarResale(CarResale $carResale): self
  505.     {
  506.         if ($this->carResales->removeElement($carResale)) {
  507.             // set the owning side to null (unless already changed)
  508.             if ($carResale->getCar() === $this) {
  509.                 $carResale->setCar(null);
  510.             }
  511.         }
  512.         return $this;
  513.     }
  514.     public function getBranches(): ?Branches
  515.     {
  516.         return $this->branches;
  517.     }
  518.     public function setBranches(?Branches $branches): self
  519.     {
  520.         $this->branches $branches;
  521.         return $this;
  522.     }
  523.     public function getFeaturesInfoauto(): ?string
  524.     {
  525.         return $this->featuresInfoauto;
  526.     }
  527.     public function setFeaturesInfoauto(?string $featuresInfoauto): self
  528.     {
  529.         $this->featuresInfoauto $featuresInfoauto;
  530.         return $this;
  531.     }
  532.     public function getColor(): ?string
  533.     {
  534.         return $this->color;
  535.     }
  536.     public function setColor(?string $color): self
  537.     {
  538.         $this->color $color;
  539.         return $this;
  540.     }
  541.     public function getDestination(): ?Destinations
  542.     {
  543.         return $this->destination;
  544.     }
  545.     public function setDestination(?Destinations $destination): self
  546.     {
  547.         $this->destination $destination;
  548.         return $this;
  549.     }
  550.     public function getIsOpportunity(): ?bool
  551.     {
  552.         return $this->isOpportunity;
  553.     }
  554.     public function setIsOpportunity(?bool $isOpportunity): self
  555.     {
  556.         $this->isOpportunity $isOpportunity;
  557.         return $this;
  558.     }
  559.     public function getIs0km(): ?bool
  560.     {
  561.         return $this->is0km;
  562.     }
  563.     public function setIs0km(?bool $is0km): self
  564.     {
  565.         $this->is0km $is0km;
  566.         return $this;
  567.     }
  568.     public function getIsImmediateDelivery(): ?bool
  569.     {
  570.         return $this->isImmediateDelivery;
  571.     }
  572.     public function setIsImmediateDelivery(?bool $isImmediateDelivery): self
  573.     {
  574.         $this->isImmediateDelivery $isImmediateDelivery;
  575.         return $this;
  576.     }
  577. }