src/Entity/Pos.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PosRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassPosRepository::class)]
  9. class Pos
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  16.     private ?\DateTimeInterface $dateStart null;
  17.     #[ORM\Column(typeTypes::DATETIME_MUTABLE,nullabletrue)]
  18.     private ?\DateTimeInterface $dateEnd null;
  19.     #[ORM\ManyToOne(inversedBy'poss')]
  20.     #[ORM\JoinColumn(nullablefalse)]
  21.     private ?User $user null;
  22.     #[ORM\Column(nullabletrue)]
  23.     private ?float $initialAmountnull;
  24.     #[ORM\OneToMany(mappedBy'pos'targetEntityOrder::class, orphanRemovaltrue)]
  25.     private Collection $orders;
  26.     #[ORM\Column(nullabletrue)]
  27.     private ?float $finalAmount null;
  28.     public function __construct()
  29.     {
  30.         $this->orders = new ArrayCollection();
  31.         $this->initialAmount 0;
  32.         $this->finalAmount 0;
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getDateStart(): ?\DateTimeInterface
  39.     {
  40.         return $this->dateStart;
  41.     }
  42.     public function setDateStart(\DateTimeInterface $dateStart): self
  43.     {
  44.         $this->dateStart $dateStart;
  45.         return $this;
  46.     }
  47.     public function getDateEnd(): ?\DateTimeInterface
  48.     {
  49.         return $this->dateEnd;
  50.     }
  51.     public function setDateEnd(\DateTimeInterface $dateEnd): self
  52.     {
  53.         $this->dateEnd $dateEnd;
  54.         return $this;
  55.     }
  56.     public function getUser(): ?User
  57.     {
  58.         return $this->user;
  59.     }
  60.     public function setUser(?User $user): self
  61.     {
  62.         $this->user $user;
  63.         return $this;
  64.     }
  65.     public function getInitialAmount(): ?float
  66.     {
  67.         return $this->initialAmount;
  68.     }
  69.     public function setInitialAmount(float $initialAmount): self
  70.     {
  71.         $this->initialAmount $initialAmount;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return Collection<int, Order>
  76.      */
  77.     public function getOrders(): Collection
  78.     {
  79.         return $this->orders;
  80.     }
  81.     public function addOrder(Order $order): self
  82.     {
  83.         if (!$this->orders->contains($order)) {
  84.             $this->orders->add($order);
  85.             $order->setPos($this);
  86.         }
  87.         return $this;
  88.     }
  89.     public function removeOrder(Order $order): self
  90.     {
  91.         if ($this->orders->removeElement($order)) {
  92.             // set the owning side to null (unless already changed)
  93.             if ($order->getPos() === $this) {
  94.                 $order->setPos(null);
  95.             }
  96.         }
  97.         return $this;
  98.     }
  99.     public function getFinalAmount(): ?float
  100.     {
  101.         return $this->finalAmount;
  102.     }
  103.     public function setFinalAmount(?float $finalAmount): self
  104.     {
  105.         $this->finalAmount $finalAmount;
  106.         return $this;
  107.     }
  108.     public function __toString(): string
  109.     {
  110.         return $this->getUser()->getUsername();
  111.     }
  112. }