src/Entity/CarBuy.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CarBuyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass=CarBuyRepository::class)
  10.  * @ORM\HasLifecycleCallbacks()
  11.  */
  12. class CarBuy
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $price;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $origin;
  28.     /**
  29.      * @ORM\Column(type="datetime")
  30.      */
  31.     private $createdAt;
  32.     /**
  33.      * @ORM\Column(type="datetime", nullable=true)
  34.      */
  35.     private $updatedAt;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity=Car::class, inversedBy="carBuyId")
  38.      * @ORM\JoinColumn(nullable=false)
  39.      */
  40.     private $car;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="carBuyId")
  43.      */
  44.     private $user;
  45.     /**
  46.      * @ORM\Column(type="integer", nullable=true)
  47.      * @Assert\LessThan(propertyPath="price", message="It must be less than the purchase price")
  48.      */
  49.     private $moneyAdvance;
  50.     /**
  51.      * @ORM\Column(type="boolean")
  52.      */
  53.     private $isDone;
  54.     /**
  55.      * @ORM\Column(type="datetime", nullable=true)
  56.      */
  57.     private $isDoneDate;
  58.     /**
  59.      * @ORM\ManyToOne(targetEntity=Client::class, inversedBy="carBuyClientId")
  60.      */
  61.     private $client;
  62.     /**
  63.      * @ORM\Column(type="string", length=5)
  64.      */
  65.     private $currency;
  66.     /**
  67.      * @ORM\Column(type="text", nullable=true)
  68.      */
  69.     private $description;
  70.     /**
  71.      * @ORM\ManyToOne(targetEntity=Car::class, inversedBy="carSwapId")
  72.      */
  73.     private $carSwap;
  74.     /**
  75.      * @ORM\OneToMany(targetEntity=CarBuyDocument::class, mappedBy="carBuy", cascade={"persist", "remove"}, orphanRemoval=true)
  76.      */
  77.     private $documents;
  78.     public function __construct()
  79.     {
  80.         $this->documents  = new ArrayCollection();
  81.     }
  82.     public function getId(): ?int
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function getPrice(): ?int
  87.     {
  88.         return $this->price;
  89.     }
  90.     public function setPrice($price): self
  91.     {
  92.         $this->price str_replace('.'''$price);
  93.         return $this;
  94.     }
  95.     public function getOrigin(): ?string
  96.     {
  97.         return $this->origin;
  98.     }
  99.     public function setOrigin(string $origin): self
  100.     {
  101.         $this->origin $origin;
  102.         return $this;
  103.     }
  104.     public function getCreatedAt(): ?\DateTimeInterface
  105.     {
  106.         return $this->createdAt;
  107.     }
  108.     /**
  109.      * @ORM\PrePersist
  110.      */
  111.     public function setCreatedAt(): self
  112.     {
  113.         $this->createdAt = new \DateTime();
  114.         return $this;
  115.     }
  116.     public function getUpdatedAt(): ?\DateTimeInterface
  117.     {
  118.         return $this->updatedAt;
  119.     }
  120.     /**
  121.      * @ORM\PreUpdate
  122.      */
  123.     public function setUpdatedAt(): self
  124.     {
  125.         $this->updatedAt = new \DateTime();
  126.         return $this;
  127.     }
  128.     public function getCar(): ?Car
  129.     {
  130.         return $this->car;
  131.     }
  132.     public function setCar(?Car $car): self
  133.     {
  134.         $this->car $car;
  135.         return $this;
  136.     }
  137.     public function getUser(): ?User
  138.     {
  139.         return $this->user;
  140.     }
  141.     public function setUser(?User $user): self
  142.     {
  143.         $this->user $user;
  144.         return $this;
  145.     }
  146.     public function getMoneyAdvance(): ?int
  147.     {
  148.         return $this->moneyAdvance;
  149.     }
  150.     //public function setMoneyAdvance(?int $moneyAdvance): self
  151.     public function setMoneyAdvance($moneyAdvance): self
  152.     {
  153.         $this->moneyAdvance str_replace('.'''$moneyAdvance);
  154.         return $this;
  155.     }
  156.     public function getIsDone(): ?bool
  157.     {
  158.         return $this->isDone;
  159.     }
  160.     public function setIsDone(bool $isDone): self
  161.     {
  162.         $this->isDone $isDone;
  163.         return $this;
  164.     }
  165.     public function getClient(): ?Client
  166.     {
  167.         return $this->client;
  168.     }
  169.     public function setClient(?Client $client): self
  170.     {
  171.         $this->client $client;
  172.         return $this;
  173.     }
  174.     public function getCurrency(): ?string
  175.     {
  176.         return $this->currency;
  177.     }
  178.     public function setCurrency(string $currency): self
  179.     {
  180.         $this->currency $currency;
  181.         return $this;
  182.     }
  183.     public function getDescription(): ?string
  184.     {
  185.         return $this->description;
  186.     }
  187.     public function setDescription(?string $description): self
  188.     {
  189.         $this->description $description;
  190.         return $this;
  191.     }
  192.     public function getCarSwap(): ?Car
  193.     {
  194.         return $this->carSwap;
  195.     }
  196.     public function setCarSwap(?Car $carSwap): self
  197.     {
  198.         $this->carSwap $carSwap;
  199.         return $this;
  200.     }
  201.     public function getIsDoneDate(): ?\DateTimeInterface
  202.     {
  203.         return $this->isDoneDate;
  204.     }
  205.     public function setIsDoneDate(?\DateTimeInterface $isDoneDate): self
  206.     {
  207.         $this->isDoneDate $isDoneDate;
  208.         return $this;
  209.     }
  210.     /**
  211.      * @return Collection<int, CarBuyDocument>
  212.      */
  213.     public function getDocuments(): Collection
  214.     {
  215.         return $this->documents;
  216.     }
  217.     public function addDocument(CarBuyDocument $document): self
  218.     {
  219.         if (!$this->documents->contains($document)) {
  220.             $this->documents[] = $document;
  221.             $document->setCarBuy($this);
  222.         }
  223.         return $this;
  224.     }
  225.     public function removeDocument(CarBuyDocument $document): self
  226.     {
  227.         if ($this->documents->removeElement($document)) {
  228.             if ($document->getCarBuy() === $this) {
  229.                 $document->setCarBuy(null);
  230.             }
  231.         }
  232.         return $this;
  233.     }
  234. }