src/Entity/Pack.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PackRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=PackRepository::class)
  9.  */
  10. class Pack
  11. {
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      *
  24.      * @ORM\Column(type="text", nullable=true)
  25.      */
  26.     private $description;
  27.     /**
  28.      *
  29.      * @ORM\Column(type="float")
  30.      */
  31.     private $price_ttc;
  32.     /**
  33.      *
  34.      * @ORM\ManyToMany(targetEntity=File::class, cascade={"persist"})
  35.      */
  36.     private $pictures;
  37.     /**
  38.      * @ORM\ManyToMany(targetEntity=ProduitDeclinationValue::class, inversedBy="packs")
  39.      */
  40.     private $declinations;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=DocumentProduit::class, mappedBy="pack")
  43.      */
  44.     private $documentPacks;
  45.     /**
  46.      * @ORM\Column(type="boolean", nullable=true)
  47.      */
  48.     private $isArchived;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity=Produit::class)
  51.      */
  52.     private $produit1;
  53.     /**
  54.      * @ORM\ManyToOne(targetEntity=Produit::class)
  55.      */
  56.     private $produit2;
  57.     /**
  58.      * @ORM\Column(type="float", nullable=true)
  59.      */
  60.     private $remise;
  61.     public function __construct()
  62.     {
  63.         $this->declinations = new ArrayCollection();
  64.         $this->pictures = new ArrayCollection();
  65.     }
  66.     
  67.     public function getId(): ?int
  68.     {
  69.         return $this->id;
  70.     }
  71.     
  72.     public function adddeclination(ProduitDeclinationValue $declination)
  73.     {
  74.         if (!$this->declinations->contains($declination)) {
  75.             $this->declinations[] = $declination;
  76.         }
  77.     }
  78.     public function removedeclination(ProduitDeclinationValue $declination)
  79.     {
  80.         $this->declinations->removeElement($declination);
  81.     }
  82.     public function getdeclinations(): Collection
  83.     {
  84.         return $this->declinations;
  85.     }
  86.     public function getName(): ?string
  87.     {
  88.         return $this->name;
  89.     }
  90.     public function setName(string $name): self
  91.     {
  92.         $this->name $name;
  93.         return $this;
  94.     }
  95.     public function getDescription(): ?string
  96.     {
  97.         return $this->description;
  98.     }
  99.     public function setDescription(?string $description): self
  100.     {
  101.         $this->description $description;
  102.         return $this;
  103.     }
  104.     public function getPriceTtc(): ?float
  105.     {
  106.         return $this->price_ttc;
  107.     }
  108.     public function setPriceTtc(float $price_ttc): self
  109.     {
  110.         $this->price_ttc $price_ttc;
  111.         return $this;
  112.     }
  113.     /**
  114.      * @return Collection|File[]
  115.      */
  116.     public function getPicture(): Collection
  117.     {
  118.         return $this->picture;
  119.     }
  120.     public function addPicture(File $picture): self
  121.     {
  122.         if( !$this->picture->contains($picture)) {
  123.             $this->picture[] = $picture;
  124.         }
  125.         return $this;
  126.     }
  127.     public function removePicture(File $picture): self
  128.     {
  129.         $this->picture->removeElement($picture);
  130.         return $this;
  131.     }
  132.     public function getIsArchived(): ?bool
  133.     {
  134.         return $this->isArchived;
  135.     }
  136.     public function setIsArchived(?bool $isArchived): self
  137.     {
  138.         $this->isArchived $isArchived;
  139.         return $this;
  140.     }
  141.     public function getProduit1(): ?Produit
  142.     {
  143.         return $this->produit1;
  144.     }
  145.     public function setProduit1(?Produit $produit1): self
  146.     {
  147.         $this->produit1 $produit1;
  148.         return $this;
  149.     }
  150.     public function getProduit2(): ?Produit
  151.     {
  152.         return $this->produit2;
  153.     }
  154.     public function setProduit2(?Produit $produit2): self
  155.     {
  156.         $this->produit2 $produit2;
  157.         return $this;
  158.     }
  159.     public function getRemise(): ?float
  160.     {
  161.         return $this->remise;
  162.     }
  163.     public function setRemise(?float $remise): self
  164.     {
  165.         $this->remise $remise;
  166.         return $this;
  167.     }
  168.     public function getPrixApresRemise(): ?float
  169.     {
  170.         if (!$this->produit1 || !$this->produit2 || $this->remise === null) {
  171.             return null;
  172.         }
  173.         $prixOriginal $this->produit1->getPrix() + $this->produit2->getPrix();
  174.         return $prixOriginal * ($this->remise 100);
  175.     }
  176. }