src/Entity/Delivery.php line 194

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DeliveryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use JsonSerializable;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=DeliveryRepository::class)
  10.  */
  11. class Delivery implements JsonSerializable
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $name;
  23.     /**
  24.      * @ORM\Column(type="text", nullable=true)
  25.      */
  26.     private $address;
  27.     /**
  28.      * @ORM\Column(type="string", length=255, nullable=true)
  29.      */
  30.     private $phone;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private $tva;
  35.     /**
  36.      * @ORM\Column(type="float")
  37.      */
  38.     private $price;
  39.     /**
  40.      * @ORM\Column(type="float")
  41.      */
  42.     private $totalPrice;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity=Document::class, mappedBy="delivery")
  45.      */
  46.     private $documents;
  47.     /**
  48.      * @ORM\Column(type="integer", nullable=true)
  49.      */
  50.     private $position;
  51.     /**
  52.      * @ORM\Column(type="boolean", nullable=true)
  53.      */
  54.     private $isSelected;
  55.     /**
  56.     * @ORM\Column(type="string", length=255)
  57.     */private $type;
  58.     /**
  59.      * @ORM\Column(type="datetime", nullable=true)
  60.      */
  61.     private $deletedAt;
  62.     public function __construct()
  63.     {
  64.         $this->documents = new ArrayCollection();
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getName(): ?string
  71.     {
  72.         return $this->name;
  73.     }
  74.     public function setName(string $name): self
  75.     {
  76.         $this->name $name;
  77.         return $this;
  78.     }
  79.     public function getPrice(): ?float
  80.     {
  81.         return $this->price;
  82.     }
  83.     public function setPrice(float $price): self
  84.     {
  85.         $this->price $price;
  86.         return $this;
  87.     }
  88.     public function getTotalPrice(): ?float
  89.     {
  90.         return $this->totalPrice;
  91.     }
  92.     public function setTotalPrice(float $totalPrice): self
  93.     {
  94.         $this->totalPrice $totalPrice;
  95.         return $this;
  96.     }
  97.     /**
  98.      * @return Collection|Document[]
  99.      */
  100.     public function getDocuments(): Collection
  101.     {
  102.         return $this->documents;
  103.     }
  104.     public function addDocument(Document $document): self
  105.     {
  106.         if( !$this->documents->contains($document)) {
  107.             $this->documents[] = $document;
  108.             $document->setDelivery($this);
  109.         }
  110.         return $this;
  111.     }
  112.     public function removeDocument(Document $document): self
  113.     {
  114.         if( $this->documents->removeElement($document)) {
  115.             // set the owning side to null (unless already changed)
  116.             if( $document->getDelivery() === $this) {
  117.                 $document->setDelivery(null);
  118.             }
  119.         }
  120.         return $this;
  121.     }
  122.     public function getPosition(): ?int
  123.     {
  124.         return $this->position;
  125.     }
  126.     public function setPosition(?int $position): self
  127.     {
  128.         $this->position $position;
  129.         return $this;
  130.     }
  131.     public function getIsSelected(): ?bool
  132.     {
  133.         return $this->isSelected;
  134.     }
  135.     public function setIsSelected(?bool $isSelected): self
  136.     {
  137.         $this->isSelected $isSelected;
  138.         return $this;
  139.     }
  140.     public function getType(): ?string
  141.     {
  142.         return $this->type;
  143.     }
  144.     public function setType(string $type): self
  145.     {
  146.         $this->type $type;
  147.         return $this;
  148.     }
  149.     public function getDeletedAt(): ?\DateTimeInterface
  150.     {
  151.         return $this->deletedAt;
  152.     }
  153.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  154.     {
  155.         $this->deletedAt $deletedAt;
  156.         return $this;
  157.     }
  158.     public function jsonSerialize()
  159.     {
  160.         return array(
  161.             'id' => $this->getId(),
  162.             'name' => $this->getName(),
  163.             'price' => $this->getPrice(),
  164.             'amountFreeDelivery' => isset($_ENV['FREE_DELIVERY_AMOUNT']) ? floatval($_ENV['FREE_DELIVERY_AMOUNT']) : 0// Minimum de commande pour avoir une livraison gratuite
  165.         );
  166.     }
  167.     public function setAddress(string $address): self
  168.     {
  169.         $this->address $address;
  170.         return $this;
  171.     }
  172.     public function getAddress(): ?string
  173.     {
  174.         return $this->address;
  175.     }
  176.     public function setPhone(string $phone): self
  177.     {
  178.         $this->phone $phone;
  179.         return $this;
  180.     }
  181.     public function getPhone(): ?string
  182.     {
  183.         return $this->phone;
  184.     }
  185.     public function setTva(string $tva): self
  186.     {
  187.         $this->tva $tva;
  188.         return $this;
  189.     }
  190.     public function getTva(): ?string
  191.     {
  192.         return $this->tva;
  193.     }
  194. }