예제 #1
0
 public function buy()
 {
     if (Request::ajax()) {
         $id = Request::get('id');
         $qty = Request::get('qty');
         $book = book::where('id', $id)->first();
         $price = $book->price - $book->price * $book->discount / 100;
         Cart::add(['id' => $id, 'name' => $book->name, 'qty' => $qty, 'price' => $price, 'options' => ['image' => $book->image]]);
         $cart = '';
         //print_r(Cart::content()->toArray()) ;
         foreach (Cart::content() as $item) {
             $cart = $cart . '
             <div class="lica mxClrAft" id="' . $item->rowid . '">
                 <div class="ttl left">
                     <a href="' . route('home.detail', $item->id) . '" class="is-2r">
                         ' . $item->name . '
                     </a>
                 </div>
                 <div class="cartbox left">
                     <div class="num left">
                         <input type="text" class="n left" value="' . $item->qty . '">
                         <div class="ctrlnum left">
                             <div class="fa fa-angle-up is-up"></div>
                             <div class="fa fa-angle-down is-down"></div>
                         </div>
                         <div class="clear"></div>
                     </div>
                 </div>
                 <div class="sls left" value="' . $item->price . '">
                     ' . number_format($item->price, 0, ',', '.') . 'đ
                 </div>
                 <div class="fa fa-trash-o right"></div>
             </div>
             ';
         }
         $data = ['cart' => $cart, 'total' => Cart::total()];
         return $data;
     } else {
         return redirect()->route('home.index');
     }
 }
예제 #2
0
 public function showUpdateForm($id)
 {
     if (Auth::user()->role !== 1) {
         return redirect('/');
     }
     $this->book = book::where('id', '=', $id)->first();
     $book_book_cates = $this->book->book_book_cates;
     $i = 0;
     $cates = array();
     $book_cates = array();
     $book_cate_ids = array();
     foreach ($book_book_cates as $book_book_cate) {
         $book_cate = $book_book_cate->book_cate;
         $book_cates[$i] = $book_cate->name;
         $book_cate_ids[$i] = $book_cate->id;
         $cate = $book_cate->category;
         $cates[$i] = $cate->name;
         $i++;
     }
     return Controller::myView('admin_book.update')->with("book", $this->book)->with("cates", $cates)->with("book_cate_names", $book_cates)->with("book_cate_ids", $book_cate_ids);
 }
예제 #3
0
 public function cate($id)
 {
     if (Request::ajax()) {
         $limit = Request::get('limit');
         $data = Request::get('data');
         $sort = Request::get('sort');
         $list = Request::get('list');
         $model = book::where('cate_id', $id)->where('publishing_date', '<', date('y-m-d'))->orderBy('publishing_date', 'DESC');
         $model = HomeController::sort($model, $sort)->paginate($limit);
         return view('front.partials.list_book_item_info_page', ['data' => $model, 'list' => $list]);
     }
     $bestsellers = book::where('publishing_date', '<', date('y-m-d'))->orderBy('qty_saled', 'DESC')->paginate(5);
     $cate_name = cate::where('id', $id)->first()->name;
     return view('front.xemthem', ['data' => $bestsellers, 'name' => $cate_name]);
 }