src/Order/Doctrine/Entity/Bill.php line 28

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Order\Doctrine\Entity;
  4. use App\Supplier\Doctrine\Entity\Supplier;
  5. use DateTimeImmutable;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping\Column;
  9. use Doctrine\ORM\Mapping\Entity;
  10. use Doctrine\ORM\Mapping\GeneratedValue;
  11. use Doctrine\ORM\Mapping\Id;
  12. use Doctrine\ORM\Mapping\JoinColumn;
  13. use Doctrine\ORM\Mapping\ManyToOne;
  14. use Doctrine\ORM\Mapping\OneToMany;
  15. use Doctrine\ORM\Mapping\Table;
  16. use Symfony\Component\HttpFoundation\File\File;
  17. use Symfony\Component\Validator\Constraints\NotBlank;
  18. use Symfony\Component\Validator\Constraints\NotNull;
  19. use Vich\UploaderBundle\Mapping\Annotation\Uploadable;
  20. use Vich\UploaderBundle\Mapping\Annotation\UploadableField;
  21. #[Uploadable]
  22. #[Entity]
  23. #[Table(name'order_bill')]
  24. class Bill
  25. {
  26.     #[Id]
  27.     #[Column(type'integer')]
  28.     #[GeneratedValue]
  29.     private ?int $id null;
  30.     #[Column(type'date_immutable')]
  31.     #[NotBlank]
  32.     private DateTimeImmutable $createdAt;
  33.     #[ManyToOne(targetEntitySupplier::class)]
  34.     #[JoinColumn(nullablefalse)]
  35.     #[NotNull]
  36.     private Supplier $supplier;
  37.     /**
  38.      * @var Collection<int, Detail>
  39.      */
  40.     #[OneToMany(mappedBy'bill'targetEntityDetail::class)]
  41.     private Collection $details;
  42.     #[Column]
  43.     private string $path;
  44.     #[UploadableField(mapping'bills'fileNameProperty'path')]
  45.     private ?File $file null;
  46.     public function __construct()
  47.     {
  48.         $this->details = new ArrayCollection();
  49.         $this->createdAt = new DateTimeImmutable();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getCreatedAt(): DateTimeImmutable
  56.     {
  57.         return $this->createdAt;
  58.     }
  59.     public function setCreatedAt(DateTimeImmutable $createdAt): void
  60.     {
  61.         $this->createdAt $createdAt;
  62.     }
  63.     public function getSupplier(): Supplier
  64.     {
  65.         return $this->supplier;
  66.     }
  67.     public function setSupplier(Supplier $supplier): void
  68.     {
  69.         $this->supplier $supplier;
  70.     }
  71.     /**
  72.      * @return Collection<int, Detail>
  73.      */
  74.     public function getDetails(): Collection
  75.     {
  76.         return $this->details;
  77.     }
  78.     /**
  79.      * @param Collection $details
  80.      */
  81.     public function setDetails(Collection $details): void
  82.     {
  83.         $this->details $details;
  84.     }
  85.     public function removeDetail(Detail $detail): void
  86.     {
  87.         $this->details->removeElement($detail);
  88.     }
  89.     public function addDetail(Detail $detail): self
  90.     {
  91.         if (!$this->details->contains($detail)) {
  92.             $this->details[] = $detail;
  93.             $detail->setBill($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function getPath(): string
  98.     {
  99.         return $this->path;
  100.     }
  101.     public function setPath(string $path): void
  102.     {
  103.         $this->path $path;
  104.     }
  105.     public function getFile(): ?File
  106.     {
  107.         return $this->file;
  108.     }
  109.     public function setFile(?File $file): void
  110.     {
  111.         $this->file $file;
  112.     }
  113. }