Beispiel #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     cart::create(['c_id' => 1, 'b_id' => 1]);
     cart::create(['c_id' => 1, 'b_id' => 3]);
     cart::create(['c_id' => 1, 'b_id' => 5]);
     cart::create(['c_id' => 1, 'b_id' => 7]);
     cart::create(['c_id' => 2, 'b_id' => 2]);
     cart::create(['c_id' => 2, 'b_id' => 4]);
     cart::create(['c_id' => 2, 'b_id' => 6]);
     cart::create(['c_id' => 2, 'b_id' => 8]);
 }
Beispiel #2
0
 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');
 }