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/BasketItem.php line 83

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BasketItemRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use JsonSerializable;
  6. /**
  7.  * @ORM\Entity(repositoryClass=BasketItemRepository::class)
  8.  */
  9. class BasketItem implements JsonSerializable
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\ManyToOne(targetEntity="Produit", inversedBy="basketItems")
  19.      * @ORM\JoinColumn(name="id_produit", referencedColumnName="id")
  20.      */
  21.     private $produit;
  22.     /**
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $quantity;
  26.     /**
  27.      * @ORM\Column(type="integer", nullable=true)
  28.      */
  29.     private $agentId;
  30.     /**
  31.      * @ORM\Column(type="integer", nullable=true)
  32.      */
  33.     private $secteurId;
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getQuantity(): ?int
  39.     {
  40.         return $this->quantity;
  41.     }
  42.     public function setQuantity(int $quantity): self
  43.     {
  44.         $this->quantity $quantity;
  45.         return $this;
  46.     }
  47.     public function getCost()
  48.     {
  49.         return $this->getProduit()->getPrix() * $this->getQuantity();
  50.     }
  51.     public function getProduit(): ?Produit
  52.     {
  53.         return $this->produit;
  54.     }
  55.     public function setProduit(Produit $produit): self
  56.     {
  57.         $this->produit $produit;
  58.         return $this;
  59.     }
  60.     public function __construct($produitint $quantity){
  61.         $this->produit $produit;
  62.         $this->quantity $quantity;
  63.     }
  64.     public function jsonSerialize()
  65.     {
  66.         $vars get_object_vars($this);
  67.         return $vars;
  68.     }
  69.     public function getAgentId(): ?int
  70.     {
  71.         return $this->agentId;
  72.     }
  73.     public function setAgentId(?int $agentId): self
  74.     {
  75.         $this->agentId $agentId;
  76.         return $this;
  77.     }
  78.     public function getSecteurId(): ?int
  79.     {
  80.         return $this->secteurId;
  81.     }
  82.     public function setSecteurId(?int $secteurId): self
  83.     {
  84.         $this->secteurId $secteurId;
  85.         return $this;
  86.     }
  87.     public static function getGroupKeyStatic($agentId$secteurId){
  88.         return $agentId."-".$secteurId;
  89.     }
  90.     public function getGroupKey(){
  91.         return BasketItem::getGroupKeyStatic($this->getAgentId(), $this->getSecteurId());
  92.     }
  93. }