Deprecated: Constant E_STRICT is deprecated in /var/www/PixelForce/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /var/www/PixelForce/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

src/Entity/Pack.php line 152

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PackRepository;
  4. use Cocur\Slugify\Slugify;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use JsonSerializable;
  9. /**
  10.  * @ORM\Entity(repositoryClass=PackRepository::class)
  11.  */
  12. class Pack implements JsonSerializable
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255, nullable=true)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\Column(type="text", nullable=true)
  26.      */
  27.     private $description;
  28.     /**
  29.      * @ORM\Column(type="decimal", precision=10, scale=3)
  30.      */
  31.     private $cost;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity="PackCategory", inversedBy="packs")
  34.      * @ORM\JoinColumn(name="id_pack_category", referencedColumnName="id")
  35.      */
  36.     private $packCategory;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $image;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=OrderPack::class, mappedBy="agent")
  43.      */
  44.     private $orderPacks;
  45.     /**
  46.      * @ORM\Column(type="integer", nullable=true, options={"default" : 1})
  47.      */
  48.     private $status;
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=true)
  51.      */
  52.     private $document;
  53.     /**
  54.      * @ORM\OneToMany(targetEntity=PackProduct::class, mappedBy="pack", cascade={"persist"} )
  55.      */
  56.     private $products;
  57.     
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getName(): ?string
  63.     {
  64.         return $this->name;
  65.     }
  66.     public function setName(?string $name): self
  67.     {
  68.         $this->name $name;
  69.         return $this;
  70.     }
  71.     public function getDescription(): ?string
  72.     {
  73.         return $this->description;
  74.     }
  75.     public function setDescription(?string $description): self
  76.     {
  77.         $this->description $description;
  78.         return $this;
  79.     }
  80.     public function getCost(): ?string
  81.     {
  82.         return $this->cost;
  83.     }
  84.     public function setCost(string $cost): self
  85.     {
  86.         $this->cost $cost;
  87.         return $this;
  88.     }
  89.     public function getPackCategory(): ?PackCategory
  90.     {
  91.         return $this->packCategory;
  92.     }
  93.     public function setPackCategory(PackCategory $packCategory): self
  94.     {
  95.         $this->packCategory $packCategory;
  96.         return $this;
  97.     }
  98.     public function getImage(): ?string
  99.     {
  100.         return $this->image;
  101.     }
  102.     public function setImage(?string $image): self
  103.     {
  104.         $this->image $image;
  105.         return $this;
  106.     }
  107.     public function getDocument(): ?string
  108.     {
  109.         return $this->document;
  110.     }
  111.     public function setDocument(?string $document): self
  112.     {
  113.         $this->document $document;
  114.         return $this;
  115.     }
  116.     public function __construct(){
  117.         $this->orderPacks = new ArrayCollection();
  118.         $this->products = new ArrayCollection();
  119.     }
  120.     public function jsonSerialize()
  121.     {
  122.         $vars get_object_vars($this);
  123.         return $vars;
  124.     }
  125.     
  126.     public function getSlugCatPack()
  127.     {
  128.         return (new Slugify())->slugify($this->packCategory->getName()) ;
  129.     }
  130.     public function getSlugPack()
  131.     {
  132.        return  (new Slugify())->slugify($this->getName())  ;
  133.     }
  134.     /**
  135.      * @return Collection<int, OrderPack>
  136.      */
  137.     public function getOrderPacks(): Collection
  138.     {
  139.         return $this->orderPacks;
  140.     }
  141.     public function getStatus(): ?int
  142.     {
  143.         return $this->status;
  144.     }
  145.     public function setStatus(?int $status): self
  146.     {
  147.         $this->status $status;
  148.         return $this;
  149.     }
  150.     /**
  151.      * @return Collection<int, PackProduct>
  152.      */
  153.     public function getProducts(): Collection
  154.     {
  155.         return $this->products;
  156.     }
  157.     public function addProduct(PackProduct $product): self
  158.     {
  159.         if (!$this->products->contains($product)) {
  160.             $this->products[] = $product;
  161.             $product->setPack($this);
  162.         }
  163.         return $this;
  164.     }
  165.     public function removeOrderProduct(PackProduct $product): self
  166.     {
  167.         if ($this->pro->removeElement($product)) {
  168.             // set the owning side to null (unless already changed)
  169.             if ($product->getPack() === $this) {
  170.                 $product->setPack(null);
  171.             }
  172.         }
  173.         return $this;
  174.     }
  175. }