src/Entity/Orders.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\CreatedAtTrait;
  4. use App\Repository\OrdersRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassOrdersRepository::class)]
  9. class Orders
  10. {
  11.     use CreatedAtTrait;
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length20uniquetrue)]
  17.     private ?string $reference null;
  18.    
  19.     #[ORM\ManyToOne(inversedBy'orders')]
  20.     private ?Coupons $coupons null;
  21.     #[ORM\ManyToOne(inversedBy'orders')]
  22.     #[ORM\JoinColumn(nullablefalse)]
  23.     private ?Users $users null;
  24.     #[ORM\OneToMany(mappedBy'orders'targetEntityOrdersDetails::class, orphanRemovaltruecascade: ['persist'])]
  25.     private Collection $ordersDetails;
  26.     public function __construct()
  27.     {
  28.         $this->ordersDetails = new ArrayCollection();
  29.         $this->created_at = new \DateTimeImmutable();
  30.         //// $this->createdAt = new \DateTimeImmutable(); /////////////////
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getReference(): ?string
  37.     {
  38.         return $this->reference;
  39.     }
  40.     public function setReference(string $reference): static
  41.     {
  42.         $this->reference $reference;
  43.         return $this;
  44.     }
  45.     public function getCoupons(): ?Coupons
  46.     {
  47.         return $this->coupons;
  48.     }
  49.     public function setCoupons(?Coupons $coupons): static
  50.     {
  51.         $this->coupons $coupons;
  52.         return $this;
  53.     }
  54.     public function getUsers(): ?Users
  55.     {
  56.         return $this->users;
  57.     }
  58.     public function setUsers(?Users $users): static
  59.     {
  60.         $this->users $users;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return Collection<int, OrdersDetails>
  65.      */
  66.     public function getOrdersDetails(): Collection
  67.     {
  68.         return $this->ordersDetails;
  69.     }
  70.     public function addOrdersDetail(OrdersDetails $ordersDetail): static
  71.     {
  72.         if (!$this->ordersDetails->contains($ordersDetail)) {
  73.             $this->ordersDetails->add($ordersDetail);
  74.             $ordersDetail->setOrders($this);
  75.         }
  76.         return $this;
  77.     }
  78.     public function removeOrdersDetail(OrdersDetails $ordersDetail): static
  79.     {
  80.         if ($this->ordersDetails->removeElement($ordersDetail)) {
  81.             // set the owning side to null (unless already changed)
  82.             if ($ordersDetail->getOrders() === $this) {
  83.                 $ordersDetail->setOrders(null);
  84.             }
  85.         }
  86.         return $this;
  87.     }
  88. }