src/Service/PanierService.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  4. class PanierService
  5. {
  6.   protected  $session;
  7.     /**
  8.      * PanierService constructor.
  9.      * @param $session
  10.      */
  11.     public function __constructSessionInterface $session)
  12.     {
  13.         $this->session $session;
  14.     }
  15.     public function ajout(int $id){
  16.     $panier $this->session->get('panier',[]);
  17.     //dd($id);
  18.         if (empty($panier[$id])){
  19.             $panier[$id] = ;
  20.         }
  21.         else{
  22.             $panier[$id]++;
  23.         }
  24.     $this->session->set('panier',$panier);
  25.    // dd( $this->session->get('panier'));
  26.     }
  27. }