コード例 #1
0
ファイル: UserController.php プロジェクト: Amina24/Boot-Camp
 public function show_trans()
 {
     //session_start();
     $uid = $_SESSION['user_id'];
     if (isset($uid)) {
         $tr = trans::where('u_id', $uid)->get()->toArray();
         return view('trans', compact('tr'));
     } else {
         $msg = "You are not Login , Please Login First...";
         return view('login')->with('message', $msg);
     }
 }
コード例 #2
0
ファイル: BookController.php プロジェクト: Amina24/Boot-Camp
 public function buy_books()
 {
     // session_start();
     if (!isset($_SESSION['user_id'])) {
         $msg = "You are not Login , Please Login First...";
         return view('login')->with('message', $msg);
     }
     $price = 0;
     $cid = cart::max('c_id') + 1;
     foreach ($_SESSION['cart'] as $item) {
         cart::create(['b_id' => $item["id"], 'c_id' => $cid]);
         $b = Book::where('b_id', $item["id"])->first();
         $price = $price + $b->price;
     }
     trans::create(['u_id' => $_SESSION['user_id'], 'c_id' => $cid, 'amount' => $price]);
     $_SESSION['cart'] = array();
     $msg = "Thank you for buying, Book are added to your transaction...";
     return redirect()->action('UserController@show_trans');
 }