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