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.   
  163.       /**
  164.      * @ORM\Column(type="boolean", options={"default": false})
  165.      */
  166.     private bool $isActive false;
  167.     public function __construct()
  168.     {
  169.         $this->imageId = new ArrayCollection();
  170.         $this->carBuyId = new ArrayCollection();
  171.         $this->carSaleId = new ArrayCollection();
  172.         $this->carSalePaymentId = new ArrayCollection();
  173.         $this->carSwapId = new ArrayCollection();
  174.         $this->carResales = new ArrayCollection();
  175.     }
  176.     public function getId(): ?int
  177.     {
  178.         return $this->id;
  179.     }
  180.     public function getName(): ?string
  181.     {
  182.         return $this->name;
  183.     }
  184.     public function setName(string $name): self
  185.     {
  186.         $this->name $name;
  187.         return $this;
  188.     }
  189.     public function getYear(): ?int
  190.     {
  191.         return $this->year;
  192.     }
  193.     public function setYear(int $year): self
  194.     {
  195.         $this->year $year;
  196.         return $this;
  197.     }
  198.     public function getDescription(): ?string
  199.     {
  200.         return $this->description;
  201.     }
  202.     public function setDescription(?string $description): self
  203.     {
  204.         $this->description $description;
  205.         return $this;
  206.     }
  207.     public function getCreatedAt(): ?\DateTimeInterface
  208.     {
  209.         return $this->createdAt;
  210.     }
  211.     /**
  212.      * @ORM\PrePersist
  213.      */
  214.     public function setCreatedAt(): self
  215.     {
  216.         $this->createdAt = new \DateTime();
  217.         return $this;
  218.     }
  219.     public function getUpdatedAt(): ?\DateTimeInterface
  220.     {
  221.         return $this->updatedAt;
  222.     }
  223.     /**
  224.      * @ORM\PreUpdate
  225.      */
  226.     public function setUpdatedAt(): self
  227.     {
  228.         $this->updatedAt = new \DateTime();
  229.         return $this;
  230.     }
  231.     public function getUpdatedBy(): ?User
  232.     {
  233.         return $this->updatedBy;
  234.     }
  235.     public function setUpdatedBy(?User $updatedBy): self
  236.     {
  237.         $this->updatedBy $updatedBy;
  238.         return $this;
  239.     }
  240.     public function getKm(): ?int
  241.     {
  242.         return $this->km;
  243.     }
  244.     public function setKm(?int $km): self
  245.     {
  246.         $this->km $km;
  247.         return $this;
  248.     }
  249.     public function getPatent(): ?string
  250.     {
  251.         return $this->patent;
  252.     }
  253.     public function setPatent(string $patent): self
  254.     {
  255.         $this->patent $patent;
  256.         return $this;
  257.     }
  258.     public function getPricePurchase(): ?int
  259.     {
  260.         return $this->pricePurchase;
  261.     }
  262.     public function setPricePurchase($pricePurchase): self
  263.     {
  264.         $this->pricePurchase str_replace('.'''$pricePurchase);
  265.         return $this;
  266.     }
  267.     public function getPriceSale(): ?int
  268.     {
  269.         return $this->priceSale;
  270.     }
  271.     public function setPriceSale($priceSale): self
  272.     {
  273.         $this->priceSale str_replace('.'''$priceSale);
  274.         return $this;
  275.     }
  276.     public function getBrand(): ?Brand
  277.     {
  278.         return $this->brand;
  279.     }
  280.     public function setBrand(?Brand $brand): self
  281.     {
  282.         $this->brand $brand;
  283.         return $this;
  284.     }
  285.     public function getPriceCurrency(): ?string
  286.     {
  287.         return $this->priceCurrency;
  288.     }
  289.     public function setPriceCurrency(string $priceCurrency): self
  290.     {
  291.         $this->priceCurrency $priceCurrency;
  292.         return $this;
  293.     }
  294.     public function getPriceCurrencyPurchase(): ?string
  295.     {
  296.         return $this->priceCurrencyPurchase;
  297.     }
  298.     public function setPriceCurrencyPurchase(string $priceCurrencyPurchase): self
  299.     {
  300.         $this->priceCurrencyPurchase $priceCurrencyPurchase;
  301.         return $this;
  302.     }
  303.     public function getPriceCurrencySale(): ?string
  304.     {
  305.         return $this->priceCurrencySale;
  306.     }
  307.     public function setPriceCurrencySale(string $priceCurrencySale): self
  308.     {
  309.         $this->priceCurrencySale $priceCurrencySale;
  310.         return $this;
  311.     }
  312.     /**
  313.      * @return Collection|CarImages[]
  314.      */
  315.     public function getImageId(): Collection
  316.     {
  317.         return $this->imageId;
  318.     }
  319.     public function addImageId(CarImages $img): self
  320.     {
  321.         if (!$this->imageId->contains($img)) {
  322.             $img->setCar($this);
  323.             if ($img->getPosition() === 0) {
  324.                 $img->setPosition($this->imageId->count());
  325.             }
  326.             $this->imageId->add($img);
  327.         }
  328.         return $this;
  329.     }
  330.     public function removeImageId(CarImages $imageId): self
  331.     {
  332.         if ($this->imageId->removeElement($imageId)) {
  333.             // set the owning side to null (unless already changed)
  334.             if ($imageId->getCar() === $this) {
  335.                 $imageId->setCar(null);
  336.             }
  337.         }
  338.         return $this;
  339.     }
  340.     public function getFeatures(): ?array
  341.     {
  342.         if ($this->features) {
  343.             return $this->features;
  344.         } else {
  345.             $empty[] = null;
  346.             return $empty;
  347.         }
  348.     }
  349.     public function setFeatures(?array $features): self
  350.     {
  351.         $this->features $features;
  352.         return $this;
  353.     }
  354.     /**
  355.      * @return Collection|CarBuy[]
  356.      */
  357.     public function getCarBuyId(): Collection
  358.     {
  359.         return $this->carBuyId;
  360.     }
  361.     public function addCarBuyId(CarBuy $carBuyId): self
  362.     {
  363.         if (!$this->carBuyId->contains($carBuyId)) {
  364.             $this->carBuyId[] = $carBuyId;
  365.             $carBuyId->setCar($this);
  366.         }
  367.         return $this;
  368.     }
  369.     public function removeCarBuyId(CarBuy $carBuyId): self
  370.     {
  371.         if ($this->carBuyId->removeElement($carBuyId)) {
  372.             // set the owning side to null (unless already changed)
  373.             if ($carBuyId->getCar() === $this) {
  374.                 $carBuyId->setCar(null);
  375.             }
  376.         }
  377.         return $this;
  378.     }
  379.     public function __toString()
  380.     {
  381.         return $this->name.' ('.$this->patent.')';
  382.     }
  383.     /**
  384.      * @return Collection|CarSale[]
  385.      */
  386.     public function getCarSaleId(): Collection
  387.     {
  388.         return $this->carSaleId;
  389.     }
  390.     public function addCarSaleId(CarSale $carSaleId): self
  391.     {
  392.         if (!$this->carSaleId->contains($carSaleId)) {
  393.             $this->carSaleId[] = $carSaleId;
  394.             $carSaleId->setCarSale($this);
  395.         }
  396.         return $this;
  397.     }
  398.     public function removeCarSaleId(CarSale $carSaleId): self
  399.     {
  400.         if ($this->carSaleId->removeElement($carSaleId)) {
  401.             // set the owning side to null (unless already changed)
  402.             if ($carSaleId->getCarSale() === $this) {
  403.                 $carSaleId->setCarSale(null);
  404.             }
  405.         }
  406.         return $this;
  407.     }
  408.     /**
  409.      * @return Collection|CarSale[]
  410.      */
  411.     public function getCarSalePaymentId(): Collection
  412.     {
  413.         return $this->carSalePaymentId;
  414.     }
  415.     public function addCarSalePaymentId(CarSale $carSalePaymentId): self
  416.     {
  417.         if (!$this->carSalePaymentId->contains($carSalePaymentId)) {
  418.             $this->carSalePaymentId[] = $carSalePaymentId;
  419.             $carSalePaymentId->setCarSalePayment($this);
  420.         }
  421.         return $this;
  422.     }
  423.     public function removeCarSalePaymentId(CarSale $carSalePaymentId): self
  424.     {
  425.         if ($this->carSalePaymentId->removeElement($carSalePaymentId)) {
  426.             // set the owning side to null (unless already changed)
  427.             if ($carSalePaymentId->getCarSalePayment() === $this) {
  428.                 $carSalePaymentId->setCarSalePayment(null);
  429.             }
  430.         }
  431.         return $this;
  432.     }
  433.     public function getStatus(): ?string
  434.     {
  435.         return $this->status;
  436.     }
  437.     public function setStatus(?string $status): self
  438.     {
  439.         $this->status $status;
  440.         return $this;
  441.     }
  442.     /**
  443.      * @return Collection|CarBuy[]
  444.      */
  445.     public function getCarSwapId(): Collection
  446.     {
  447.         return $this->carSwapId;
  448.     }
  449.     public function addCarSwapId(CarBuy $carSwapId): self
  450.     {
  451.         if (!$this->carSwapId->contains($carSwapId)) {
  452.             $this->carSwapId[] = $carSwapId;
  453.             $carSwapId->setCarSwap($this);
  454.         }
  455.         return $this;
  456.     }
  457.     public function removeCarSwapId(CarBuy $carSwapId): self
  458.     {
  459.         if ($this->carSwapId->removeElement($carSwapId)) {
  460.             // set the owning side to null (unless already changed)
  461.             if ($carSwapId->getCarSwap() === $this) {
  462.                 $carSwapId->setCarSwap(null);
  463.             }
  464.         }
  465.         return $this;
  466.     }
  467.     public function getEngineNumber(): ?string
  468.     {
  469.         return $this->engineNumber;
  470.     }
  471.     public function setEngineNumber(?string $engineNumber): self
  472.     {
  473.         $this->engineNumber $engineNumber;
  474.         return $this;
  475.     }
  476.     public function getChassisNumber(): ?string
  477.     {
  478.         return $this->chassisNumber;
  479.     }
  480.     public function setChassisNumber(?string $chassisNumber): self
  481.     {
  482.         $this->chassisNumber $chassisNumber;
  483.         return $this;
  484.     }
  485.     public function getType(): ?string
  486.     {
  487.         return $this->type;
  488.     }
  489.     public function setType(?string $type): self
  490.     {
  491.         $this->type $type;
  492.         return $this;
  493.     }
  494.     public function getSettlement(): ?string
  495.     {
  496.         return $this->settlement;
  497.     }
  498.     public function setSettlement(?string $settlement): self
  499.     {
  500.         $this->settlement $settlement;
  501.         return $this;
  502.     }
  503.     public function getPosition(): ?int
  504.     {
  505.         return $this->position;
  506.     }
  507.     public function setPosition(int $position): self
  508.     {
  509.         $this->position $position;
  510.         return $this;
  511.     }
  512.     /**
  513.      * @return Collection<int, CarResale>
  514.      */
  515.     public function getCarResales(): Collection
  516.     {
  517.         return $this->carResales;
  518.     }
  519.     public function addCarResale(CarResale $carResale): self
  520.     {
  521.         if (!$this->carResales->contains($carResale)) {
  522.             $this->carResales[] = $carResale;
  523.             $carResale->setCar($this);
  524.         }
  525.         return $this;
  526.     }
  527.     public function removeCarResale(CarResale $carResale): self
  528.     {
  529.         if ($this->carResales->removeElement($carResale)) {
  530.             // set the owning side to null (unless already changed)
  531.             if ($carResale->getCar() === $this) {
  532.                 $carResale->setCar(null);
  533.             }
  534.         }
  535.         return $this;
  536.     }
  537.     public function getBranches(): ?Branches
  538.     {
  539.         return $this->branches;
  540.     }
  541.     public function setBranches(?Branches $branches): self
  542.     {
  543.         $this->branches $branches;
  544.         return $this;
  545.     }
  546.     public function getFeaturesInfoauto(): ?string
  547.     {
  548.         return $this->featuresInfoauto;
  549.     }
  550.     public function setFeaturesInfoauto(?string $featuresInfoauto): self
  551.     {
  552.         $this->featuresInfoauto $featuresInfoauto;
  553.         return $this;
  554.     }
  555.     public function getColor(): ?string
  556.     {
  557.         return $this->color;
  558.     }
  559.     public function setColor(?string $color): self
  560.     {
  561.         $this->color $color;
  562.         return $this;
  563.     }
  564.     public function getDestination(): ?Destinations
  565.     {
  566.         return $this->destination;
  567.     }
  568.     public function setDestination(?Destinations $destination): self
  569.     {
  570.         $this->destination $destination;
  571.         return $this;
  572.     }
  573.     public function getIsOpportunity(): ?bool
  574.     {
  575.         return $this->isOpportunity;
  576.     }
  577.     public function setIsOpportunity(?bool $isOpportunity): self
  578.     {
  579.         $this->isOpportunity $isOpportunity;
  580.         return $this;
  581.     }
  582.     public function getIs0km(): ?bool
  583.     {
  584.         return $this->is0km;
  585.     }
  586.     public function setIs0km(?bool $is0km): self
  587.     {
  588.         $this->is0km $is0km;
  589.         return $this;
  590.     }
  591.     public function getIsImmediateDelivery(): ?bool
  592.     {
  593.         return $this->isImmediateDelivery;
  594.     }
  595.     public function setIsImmediateDelivery(?bool $isImmediateDelivery): self
  596.     {
  597.         $this->isImmediateDelivery $isImmediateDelivery;
  598.         return $this;
  599.     }
  600.     public function getIsConsignacion(): ?bool
  601.     {
  602.         return $this->isConsignacion;
  603.     }
  604.     public function setIsConsignacion(?bool $isConsignacion): self
  605.     {
  606.         $this->isConsignacion $isConsignacion;
  607.         return $this;
  608.     }
  609.   
  610.       public function getIsActive(): ?bool
  611.     {
  612.         return $this->isActive;
  613.     }
  614.     public function setIsActive(?bool $isActive): self
  615.     {
  616.         $this->isActive $isActive;
  617.         return $this;
  618.     }
  619. }