/**
  * Add a product to the cart, if the product id already exists then increment its quantity
  * @param integer  $id
  * @param string  $name
  * @param integer  $price
  * @param integer $quantity
  * @param array   $options
  * @return array
  */
 public function add($id, $name = '', $price = 0, $quantity = 1, array $options = [])
 {
     $cartItems = $this->getCartSession();
     foreach ($cartItems as &$cartItem) {
         if ($cartItem['id'] == $id) {
             $cartItem['quantity'] = $cartItem['quantity'] + $quantity;
             $this->session->set(config('sescart.session_name'), $cartItems);
             return $cartItem;
         }
     }
     $newItem = ['id' => $id, 'name' => $name, 'price' => $price, 'quantity' => $quantity, 'options' => $options];
     $this->session->push(config('sescart.session_name'), $newItem);
     return $newItem;
 }
Exemple #2
0
 /**
  * Sets the location property to the drivers returned location object.
  *
  * @param string $ip
  */
 private function setLocation($ip = '')
 {
     // The location session key.
     $key = 'location';
     // Removes location from the session if config option is set
     if ($this->localHostForgetLocation()) {
         $this->session->forget($key);
     }
     // Check if the location has already been set in the current session
     if ($this->session->has($key)) {
         // Set the current driver to the current session location
         $this->location = $this->session->get($key);
     } else {
         $this->setIp($ip);
         $this->location = $this->driver->get($this->ip);
         // The locations object property 'error' will be true if an
         // exception has occurred trying to grab the location
         // from the driver. Let's try retrieving the
         // location from one of our fall-backs
         if ($this->location->error) {
             $this->location = $this->getLocationFromFallback();
         }
         $this->session->set($key, $this->location);
     }
 }
Exemple #3
0
 /**
  * @author LAHAXE Arnaud
  *
  * @param \App\User $user
  * @param           $authData
  * @param           $keyData
  *
  * @return bool
  */
 public function doAuthenticate(User $user, $authData, $keyData)
 {
     $reg = $this->u2f->doAuthenticate($authData, U2fKey::where('user_id', $user->id)->get()->all(), $keyData);
     $U2fKey = U2fKey::where(['user_id' => $user->id, 'publicKey' => $reg->publicKey])->first();
     if (is_null($U2fKey)) {
         return false;
     }
     $U2fKey->counter = $reg->counter;
     $U2fKey->save();
     $this->session->set($this->config->get('u2f.sessionU2fName'), true);
     return $U2fKey;
 }
Exemple #4
0
 /**
  * Sets the location property to the drivers returned location object.
  *
  * @param string $ip
  */
 private function setLocation($ip = '')
 {
     /*
      * Removes location from the session if config option is set
      */
     if ($this->localHostForgetLocation()) {
         $this->session->forget('location');
     }
     /*
      * Check if the location has already been set in the current session
      */
     if ($this->session->has('location')) {
         /*
          * Set the current driver to the current session location
          */
         $this->location = $this->session->get('location');
     } else {
         /*
          * Set the IP
          */
         $this->setIp($ip);
         /*
          * Set the location
          */
         $this->location = $this->driver->get($this->ip);
         /*
          * The locations object property 'error' will be true if an exception has
          * occurred trying to grab the location from the driver. Let's
          * try retrieving the location from one of our fall-backs
          */
         if ($this->location->error) {
             $this->location = $this->getLocationFromFallback();
         }
         $this->session->set('location', $this->location);
     }
 }
 /**
  * Recent / Providers
  * @param $provider
  * @param $data
  */
 public function setAuthData($provider, $data)
 {
     $this->session->set('__sp_auth.r', $provider);
     $this->session->set('__sp_auth.p.' . $provider, array_merge(['provider' => $provider], $data));
     $this->session->save();
 }
Exemple #6
0
 public function removeSectionData($section)
 {
     $this->sessionManager->set($section, null);
 }