Esempio n. 1
0
 public function index()
 {
     //Если в сессии у пользователя есть товары
     if (session()->has('products')) {
         //и массив с товарами НЕ пустой
         if (!empty(session()->get('products'))) {
             //Заносим в переменную массив ключей продуктов
             // $idOfProducts = session()->get('products');
             /*Заносим в переменную результат выборки в БД продуктов
               для показа пользователю в его корзине*/
             $cartProducts = Notebook::showInCart()->get();
             // dd($cartProducts);
             $countOfProducts = '(' . Notebook::$count . ')';
         } else {
             //Если товара нет,то заносим в переменную сообщение
             $answer = 'У вас нет товаров в корзине';
             // $countOfProducts = null;
         }
     } else {
         $answer = 'У вас нет товаров в корзине';
     }
     // dd(session()->all());
     return view('user.cart', compact('answer', 'cartProducts', 'countOfProducts'));
 }
Esempio n. 2
0
 public function addReply($id)
 {
     $comments = Notebook::find($id)->comments;
     return view('notebooks.comments', compact('comments'));
 }
Esempio n. 3
0
 public function characteristics($id)
 {
     $note = Notebook::find($id);
     //  dd($note->operationSystem);
     return view('notebooks.characteristics', compact('note'));
 }
 public function createNotebook(Request $request, $id)
 {
     $data = Request::all();
     $image = Input::file('image');
     if ($image != null) {
         $destinationPath = 'uploads';
         // upload path
         $extension = Input::file('image')->getClientOriginalExtension();
         // getting image extension
         $fileName = $image->getClientOriginalName();
         Input::file('image')->move($destinationPath, $fileName);
         // uploading file to given path
         // sending back with message
         $notebook = new Notebook();
         $notebook->NotebookTitle = $data['title'];
         $notebook->NotebookDesc = $data['description'];
         $notebook->NotebookPicture = $fileName;
         $notebook->createdBy = Session::get('userId');
         $notebook->save();
         Session::flash('success', 'Create success');
         return Redirect::to('/home');
     } else {
         Session::flash('success', 'Create fail');
         return Redirect::to('/home');
     }
 }