Esempio n. 1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check() && $this->auth->user()['status'] === 'teacher') {
         return $next($request);
     }
     Session::push('messages', 'danger|Vous devez être professeur pour accéder à cette page');
     return redirect('/');
 }
Esempio n. 2
0
 /**
  * @return \Illuminate\Http\RedirectResponse
  */
 public function bagAddBySession()
 {
     $product_id = Input::get('product_id');
     // id du produit récupéré au click au moment d'ajouter un produit
     $quantity = Input::get('quantity');
     $product = Product::where('id', $product_id)->firstOrFail();
     Session::push('panier', ["quantity" => $quantity, "product_id" => $product_id, "title" => $product->title, "image" => isset($product->image->uri_mini) ? $product->image->uri_mini : '', "price" => $product->price, "priceTotalByProduct" => $quantity * $product->price]);
     return redirect()->back()->with('message', 'Produit ajouté au panier');
 }
Esempio n. 3
0
 /**
  * Build the not in id array to be evaluated in suggestions.
  *
  * @param [array]  $products, which is the real time query result
  * @param [string] $field,    which is the validation reference point
  *
  * @return [array] $needle, that is the array to be evaluated in the where not in
  */
 public function setToHaystack($products, $field = 'id')
 {
     if (empty(Session::get('suggest-listed'))) {
         Session::put('suggest-listed', []);
     }
     if (count($products) > 0) {
         foreach ($products as $value) {
             if (!in_array($value[$field], Session::get('suggest-listed'))) {
                 Session::push('suggest-listed', $value[$field]);
             }
         }
     }
     Session::save();
 }
Esempio n. 4
0
 /**
  * Get value of a RagnarokParameter attribute
  * @param $name: the name of parameter in the database
  * @param $force: force to get the parameter value of the database
  * @return mixed
  */
 public function retrieve($name, $force = false)
 {
     $RagnarokParameters = new self($this->SecParameter);
     if (self::check()) {
         $RagnarokParameters = Session::get($this->getName());
         if (property_exists($RagnarokParameters, $name)) {
             if ($force) {
                 $value = $this->SecParameter->wherename($name)->first()->value;
                 Session::push($this->getName() . $name, $value);
             }
             $value = $RagnarokParameters->{$name};
             return $value;
         }
     }
     $RagnarokParameters->{$name} = $this->SecParameter->wherename($name)->first()->value;
     Session::put($this->getName(), $RagnarokParameters);
     return $RagnarokParameters->{$name};
 }
Esempio n. 5
0
 /**
  * init Rules
  * 
  * @return \Gsdw\Permission\Helpers\Auth
  */
 public function initRules()
 {
     if (!Session::has('permission.rules')) {
         $role = self::$user->getRole();
         if (!$role) {
             $rules = [];
         } else {
             $rules = $role->getRules();
         }
         Session::push('permission.rules', $rules);
     }
     self::$rules = Session::get('permission.rules');
     self::$rules = self::$rules[0];
     return $this;
     //        $role = self::$user->getRole();
     //        if (!$role) {
     //            self::$rules = [];
     //        } else {
     //            self::$rules = $role->getRules();
     //        }
     //        return $this;
 }
Esempio n. 6
0
 /**
  * Increase the product counters.
  *
  * @param [object] $product is the object which contain the product evaluated
  * @param [array]  $data    is the method config that has all the info requeried (table field, amount to be added)
  * @param [string] $wrapper is the products session array position key.
  */
 public static function setCounters($product = null, $data = [], $wrapper = '')
 {
     if (\Auth::user() && $product != '' && count($data) > 0) {
         $_array = Session::get('products.' . $wrapper);
         //products already evaluated
         if (count($_array) == 0 || !in_array($product->id, $_array)) {
             //looked up to make sure the product is not in $wrapper array already
             foreach ($data as $key => $value) {
                 if ($key != '' && $data[$key] != '') {
                     $product->{$key} = $product->{$key} + intval($data[$key]);
                     $product->save();
                 }
             }
             Session::push('products.' . $wrapper, $product->id);
             //build product list to not increase a product more than one time per day
             Session::save();
         }
     }
 }
 /**
  * create new random number to save the grid info on it
  *
  * @return string
  */
 private function createRandomNumber()
 {
     $str_random = str_random(16);
     while (Session::has("tables." . $str_random)) {
         $str_random = str_random(16);
     }
     Session::push("tables." . $str_random, $this->table_name);
     Session::push("tables." . $str_random, json_encode($this->columns_name));
     Session::push("tables." . $str_random, json_encode($this->columns));
     return $str_random;
 }
Esempio n. 8
0
 protected function doCreateField($table_name, $field_name)
 {
     $field_bd = $this->getAttribute('field');
     $data = Session::all();
     if (!Session::has($table_name . '.' . $field_name)) {
         if ($field_bd && !Schema::hasColumn($table_name, $field_name)) {
             Session::push($table_name . '.' . $field_name, 'created');
             @(list($field, $param) = explode("|", $field_bd));
             Schema::table($table_name, function ($table) use($field_name, $field, $param) {
                 $field_add = $table->{$field}($field_name);
                 if ($param) {
                     $field_add->length($param);
                 }
             });
         } else {
             Session::push($table_name . '.' . $field_name, 'created');
         }
     }
 }
 public static function appendErrors(\Illuminate\Validation\Validator $validator)
 {
     foreach ($validator->errors()->all() as $message) {
         Session::push('field_validation_errors', $message);
     }
 }
Esempio n. 10
0
 public function addToComparison($property)
 {
     if (!in_array($property->id, Session::get('properties_in_comparison', []))) {
         Session::push('properties_in_comparison', $property->id);
     }
 }
Esempio n. 11
0
 protected function addWarningMessage($message)
 {
     if (!Session::has('errors') || Session::get('errors')->isEmpty()) {
         Session::put('warning', $message);
         Session::push('flash.old', 'warning');
     }
 }
Esempio n. 12
0
 public function updateCart(Request $request)
 {
     $item = $request->id;
     Session::forget('product');
     foreach ($item as $index => $key) {
         $result = Product::find($key);
         $image = $result->image;
         $name = $result->name;
         $price = $result->price;
         $total = $request->number[$index] * $price;
         $data = array('token' => $request->_token, 'id' => $key, 'image' => $image, 'name' => $name, 'number' => $request->number[$index], 'price' => $price, 'total' => $total);
         Session::push('product', $data);
     }
     return redirect("cart/view")->withSuccess("Shopping cart update");
 }
Esempio n. 13
0
 /**
  * Déconnecte l'utilisateur
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function getLogout(Request $request)
 {
     Session::push('messages', 'success|Vous avez bien été déconnecté');
     Auth::logout();
     return redirect('/');
 }
Esempio n. 14
0
 public function getTableAllowedIds()
 {
     if (!Session::has($this->getOptionDB('table') . "_exist")) {
         if (!Schema::hasTable($this->getOptionDB('table'))) {
             Schema::create($this->getOptionDB('table'), function ($table) {
                 $table->increments('id');
             });
         }
     }
     $this->db = DB::table($this->getOptionDB('table'));
     $this->prepareFilterValues();
     $ids = $this->db->lists('id');
     Session::push($this->getOptionDB('table') . "_exist", 'created');
     return $ids;
 }
Esempio n. 15
0
 /**
  *   function to action to deliver virtual products
  *   @param  $order_id    int
  *   @return json    message error or message success
  */
 public function storeComment(Request $request)
 {
     $order_id = $request->get('order_id');
     $text = $request->get('comment_text');
     $user = \Auth::user();
     if ($user) {
         $order = Order::find($order_id);
         //Checks if the order belongs to the current user, or if the user is the seller of the order
         if ($order->user_id == $user->id || $order->seller_id == $user->id) {
             $data = array('user_id' => $user->id, 'action_type_id' => 3, 'source_id' => $order_id, 'comment' => $text);
             $new_comment = Comment::create($data);
             if ($order->user_id == $user->id) {
                 $mail_subject = trans('email.order_commented.comment_from_user');
                 $seller_user = User::find($order->seller_id);
                 $email = $seller_user->email;
             }
             if ($order->seller_id == $user->id) {
                 $mail_subject = trans('email.order_commented.comment_from_seller');
                 $buyer_user = User::find($order->user_id);
                 $email = $buyer_user->email;
             }
             $data = ['order_id' => $order_id, 'subject' => $mail_subject, 'email_message' => $mail_subject, 'email' => $email, 'comment' => $text, 'title' => $mail_subject];
             Mail::queue('emails.order_comment', $data, function ($message) use($user, $data) {
                 $message->to($data['email'])->subject($data['subject']);
             });
         } else {
             return \Response::json(array('success' => false, 'order_id' => $order_id), 200);
         }
     } else {
         return \Response::json(array('success' => false, 'order_id' => $order_id), 200);
     }
     Session::push('message', trans('store.create_comment_modal.added_order_comment'));
     return \Response::json(array('success' => true, 'order_id' => $order_id), 200);
 }
 public function addToCart()
 {
     $realQuantity = Input::get('quantity') + 1;
     Session::push('cart.product', ['id' => Input::get('productId'), 'quantity' => $realQuantity]);
     $product = Product::findOrFail(Input::get('productId'));
     $message = $realQuantity . ' ' . $product->title . ' bien ajouté à votre panier';
     Session::flash('message', $message);
 }
Esempio n. 17
0
 /**
  * Checkout current user's cart.
  */
 public static function setGateway($gatewayKey)
 {
     if (!array_key_exists($gatewayKey, Config::get('shop.gateways'))) {
         throw new ShopException('Invalid gateway.');
     }
     static::$gatewayKey = $gatewayKey;
     static::$gateway = static::instanceGateway();
     Session::push('shop.gateway', $gatewayKey);
 }