public function purchased(PurchaseRequest $request)
 {
     //return $request->purchase;
     $ship = Ship::findOrFail($request->ship_id);
     $strippen = $ship->strippen_total;
     $strippen += $request->purchase;
     $ship->strippen_total = $strippen;
     $ship->save();
     return redirect('ships');
 }
 public function create_helper_confirmation()
 {
     $cruiseid = Input::get('cruiseid');
     $cabinid = Input::get('cabinid');
     $cruise = Cruise::findOrFail($cruiseid);
     $ship = Ship::findOrFail($cruise->ship_id);
     $cabin = Cabin::where('id', $cabinid)->first();
     $port = Port::all();
     $cabin_type = Cruise_Cabin_Type::where('cruise_id', $cruise->id)->get();
     return view('partial.partial_confirmation', compact('cruise', 'ship', 'cabin', 'port', 'cabin_type'));
 }
                        google.maps.event.addListener(marker_<?php 
    echo $ID;
    ?>
, 'click', function() {  ib_<?php 
    echo $ID;
    ?>
.open(map, marker_<?php 
    echo $ID;
    ?>
);  });


<?php 
}
$ships = Ship::all();
foreach ($ships as $ship) {
    $ID = $ship->id;
    $shipName = $ship->shipName;
    $shipGPS = $ship->shipGPS;
    $shipHeading = $ship->shipHeading;
    ?>

var shipID = "<?php 
    echo $ID;
    ?>
";
var shipName = "<?php 
    echo $shipName;
    ?>
";
 public function delete($type, $opening_id)
 {
     $opening = Opening::findOrFail($opening_id);
     $bridge = Bridge::findOrFail($opening->bridge_id);
     $bridge->openings_total -= 1;
     $ship = Ship::findOrFail($opening->ship_id);
     $ship->strippen_total += 1;
     $bridge->save();
     $ship->save();
     $opening->delete();
     if ($type == 'ship') {
         return redirect('openings/showtype/ship/' . $ship->id);
     }
     if ($type == 'bridge') {
         return redirect('openings/showtype/bridge/' . $bridge->id);
     }
     if ($type == 'user') {
         return redirect('openings/showtype/user/1');
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $ship = Ship::find($id);
     $ship->delete($id);
     return redirect()->route('ship.index');
 }
 /**
  * Store a newly created resource in storage.
  * Check, before buy
  * @return Response
  */
 public function postCheckcart(Request $request)
 {
     if (\Auth::check()) {
         //MENU
         $mainMenu = Category::getParentMenu();
         $allMenu = Category::getAllMenu($mainMenu);
         //HOT PRODUCTS.
         $hotProduct = Product::hotProduct();
         //DISCOUNT PRODUCTS.
         $discountProduct = Product::discountProduct();
         //PAY
         $pay = Pay::find($request->get('pay'));
         if ($request->get('pay') == 2) {
             $account_number = true;
         } else {
             $account_number = false;
         }
         //SHIP
         $ship = Ship::find($request->get('ship'));
         if (\Session::has('giohang')) {
             \Session::put('pay', $pay->id);
             \Session::put('ship', $ship->id);
             return view('fornindex.shopping_cart_detail', compact('account_number', 'ship', 'pay', 'data', 'allMenu', 'hotProduct', 'discountProduct'));
         } else {
             echo 'vui long chon san pham!!!';
         }
     } else {
         return redirect('auth/login');
     }
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $transaction = Transaction::find($id);
     $customer = Customer::lists('name', 'id');
     $ship = Ship::lists('name', 'id');
     $pay = Pay::lists('name', 'id');
     return view('transactions.edit', compact('transaction', 'customer', 'ship', 'pay'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 10; ++$i) {
         Ship::create(['name' => $faker->name, 'price' => $faker->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL)]);
     }
 }