src/Entity/Cart.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use App\Repository\CartRepository;
  7. #[ORM\Entity(repositoryClass:CartRepository::class)]
  8. #[ORM\Table(name:'cart')]
  9. class Cart
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\Columntype:'integer'unique:true )]
  13.     #[ORM\GeneratedValue(strategy:'AUTO')]
  14.     private $id;
  15.     //#[ORM\ManyToOne(targetEntity:'App\Entity\User')]
  16.     #[ORM\ManyToOne(targetEntity:'App\Entity\Person'inversedBy'carts')]    
  17.     #[ORM\JoinColumn(name:'creator'referencedColumnName:'id'nullable:falseonDelete:'CASCADE')]
  18.     private $creator;
  19.     #[ORM\Column(name:'created_at'type:'datetime')]
  20.     private $createdAt;
  21.     #[ORM\OneToMany(targetEntity:Cartline::class, mappedBy:'panier'orphanRemoval:true)]
  22.     private $cartlines;
  23.     #[ORM\Column(type:'string'nullable:truelength:255)]
  24.     private $address;
  25.     #[ORM\Column(type:'float'nullable:true)]
  26.     private $total;
  27.     #[ORM\Column(nullable:truetype:'string'length:50)]
  28.     private $status;
  29.     public function __construct()
  30.     {
  31.         $this->cartlines = new ArrayCollection();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     /**
  38.      * @return mixed
  39.      */
  40.     public function getCreator()
  41.     {
  42.         return $this->creator->getId();
  43.     }
  44.     /**
  45.      * @param mixed $creator
  46.      */
  47.     public function setCreator($creator)
  48.     {
  49.         $this->creator $creator;
  50.     }
  51.     /**
  52.      * @return \DateTime
  53.      */
  54.     public function getCreatedAt()
  55.     {
  56.         return $this->createdAt;
  57.     }
  58.     /**
  59.      * @param \DateTime $createdAt
  60.      */
  61.     public function setCreatedAt($createdAt)
  62.     {
  63.         $this->createdAt $createdAt;
  64.     }
  65.     /**
  66.      * @return Collection|Cartline[]
  67.      */
  68.     public function getCartlines(): Collection
  69.     {
  70.         return $this->cartlines;
  71.     }
  72.     public function addCartline(Cartline $cartline): self
  73.     {
  74.         if (!$this->cartlines->contains($cartline)) {
  75.             $this->cartlines[] = $cartline;
  76.             $cartline->setPanier($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeCartline(Cartline $cartline): self
  81.     {
  82.         if ($this->cartlines->removeElement($cartline)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($cartline->getPanier() === $this) {
  85.                 $cartline->setPanier(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90.     public function getAddress(): ?string
  91.     {
  92.         return $this->address;
  93.     }
  94.     public function setAddress(?string $address): self
  95.     {
  96.         $this->address $address;
  97.         return $this;
  98.     }
  99.     public function getTotal(): ?float
  100.     {
  101.         return $this->total;
  102.     }
  103.     public function setTotal(?float $total): self
  104.     {
  105.         $this->total $total;
  106.         return $this;
  107.     }
  108.     public function getStatus(): ?string
  109.     {
  110.         return $this->status;
  111.     }
  112.     public function setStatus(?string $status): self
  113.     {
  114.         $this->status $status;
  115.         return $this;
  116.     }
  117. }