src/Entity/ShopPanier.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ShopPanierRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Doctrine\Persistence\Event\LifecycleEventArgs;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ShopPanierRepository::class)
  9.  * @ORM\HasLifecycleCallbacks
  10.  */
  11. class ShopPanier
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="shopPaniers")
  21.      * @ORM\JoinColumn(nullable=false)
  22.      */
  23.     private $user;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=ShopProduit::class)
  26.      * @ORM\JoinColumn(nullable=false)
  27.      */
  28.     private $produit;
  29.     /**
  30.      * @ORM\Column(type="integer")
  31.      */
  32.     private $unit;
  33.     /**
  34.     * @ORM\Column(type="datetime")
  35.     * @Gedmo\Timestampable(on="create")
  36.     */
  37.     private $createdAt;
  38.     /**
  39.      * @ORM\Column(type="datetime")
  40.      * @Gedmo\Timestampable(on="update")
  41.      */
  42.     private $updatedAt;
  43.     /**
  44.      * @ORM\Column(type="string", length=50)
  45.      */
  46.     private $domaine;
  47.     /**
  48.      * @ORM\Column(type="string", length=255)
  49.      */
  50.     private $reference;
  51.     /**
  52.      * @ORM\ManyToOne(targetEntity=ShopUserAdress::class, inversedBy="paniers")
  53.      * @ORM\JoinColumn(nullable=false)
  54.      */
  55.     private $adress;
  56.     
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getUser(): ?User
  62.     {
  63.         return $this->user;
  64.     }
  65.     public function setUser(?User $user): self
  66.     {
  67.         $this->user $user;
  68.         return $this;
  69.     }
  70.     public function getProduit(): ?ShopProduit
  71.     {
  72.         return $this->produit;
  73.     }
  74.     public function setProduit(?ShopProduit $produit): self
  75.     {
  76.         $this->produit $produit;
  77.         return $this;
  78.     }
  79.     public function getUnit(): ?int
  80.     {
  81.         return $this->unit;
  82.     }
  83.     public function setUnit(int $unit): self
  84.     {
  85.         $this->unit $unit;
  86.         return $this;
  87.     }
  88.     public function getCreatedAt(): ?\DateTimeInterface {
  89.                                    return $this->createdAt;
  90.                                }
  91.     public function setCreatedAt(?\DateTimeInterface $createdAt): self {
  92.                                    $this->createdAt $createdAt;
  93.                                                                                                 
  94.                                    return $this;
  95.                                }
  96.     public function getUpdatedAt(): ?\DateTimeInterface {
  97.                                    return $this->updatedAt;
  98.                                }
  99.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self {
  100.                                    $this->updatedAt $updatedAt;
  101.                                                                                                 
  102.                                    return $this;
  103.                                }
  104.     public function getDomaine(): ?string
  105.     {
  106.         return $this->domaine;
  107.     }
  108.     public function setDomaine(string $domaine): self
  109.     {
  110.         $this->domaine $domaine;
  111.         return $this;
  112.     }
  113.     public function getReference(): ?string
  114.     {
  115.         return $this->reference;
  116.     }
  117.     public function setReference(?string $reference=null): self
  118.     {
  119.         if (!$reference) {
  120.             $brother $this->getUser()->getShopPaniers()->filter(function($element) {
  121.                 return $element->getReference();
  122.             })->current();
  123.             if ($brother) {
  124.                 $reference $brother->getReference();
  125.             }
  126.         }
  127.         if (!$reference) {
  128.             $reference $this->getUser()->getId().date('dmYHis');
  129.         }
  130.         $this->reference $reference;
  131.         return $this;
  132.     }
  133.     /**
  134.      * @ORM\PrePersist
  135.      */
  136.     public function PrePersist(){
  137.         $this->setReference();
  138.     }
  139.     public function getAdress(): ?ShopUserAdress
  140.     {
  141.         return $this->adress;
  142.     }
  143.     public function setAdress(?ShopUserAdress $adress): self
  144.     {
  145.         $this->adress $adress;
  146.         return $this;
  147.     }
  148. }