Exemplo n.º 1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $cruise = Cruise::find($id);
     $cabins = Cabin::where('ship_id', $cruise->ship_id)->get();
     $port = Port::all();
     $cabin_type = Cruise_Cabin_Type::where('cruise_id', $cruise->id)->get();
     return view("pages.cruises_show", compact('cruise', 'cabins', 'port', 'cabin_type'));
 }
Exemplo n.º 2
0
 public function postNewCabin(Request $request)
 {
     //validate input
     $this->validate($request, ['name' => 'required|max:50', 'price' => 'required|numeric|min:0', 'size' => 'required|numeric|min:1', 'cabin_image' => 'image']);
     //create a new cabin
     $cabin = Cabin::create(['name' => $request->name, 'price' => $request->price, 'description' => $request->description, 'size' => $request->size]);
     //upload image
     if (Input::hasFile('cabin_image')) {
         $file = Input::file('cabin_image');
         $imagename = 'cabin_' . $cabin->id . '.' . Input::file('cabin_image')->getClientOriginalExtension();
         $file->move('uploads', $imagename);
         $cabin->image = $imagename;
     }
     $cabin->save();
     //Redirect to cabins page
     return redirect('/admin/cabin/' . $cabin->id)->with('status', 'Cabin created successfully!');
 }
Exemplo n.º 3
0
 public function success(Request $request, Reservation $reservation)
 {
     //change reservation status to complete
     $payment_id = Session::get('paypal_payment_id');
     $reservation->status = 1;
     $reservation->payment_id = $payment_id;
     $cruise = Cruise::find($reservation->cruise_id);
     $cabin = Cabin::find($reservation->cabin_id);
     //deduct cabin number in the cruise
     DB::table('cruises_cabins')->where('cruise_id', $reservation->cruise_id)->where('cabin_id', $reservation->cabin_id)->increment('cabin_booked');
     $reservation->save();
     Session::forget('paypal_payment_id');
     $full = 0;
     foreach ($cruise->cabins as $cabin) {
         if ($cabin->pivot->cabin_number == $cabin->pivot->cabin_booked) {
             $full++;
         }
     }
     if ($full == Cabin::all()->count()) {
         $cruise->status = 1;
         $cruise->save();
     }
     return view('user.reservation', ['cruise' => $cruise, 'cabin' => $cabin, 'amenities' => $reservation->amenities()->get(), 'reservation' => $reservation])->with('status', 'Payment succcess!');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = \Request::all();
     $passenger = new Passenger();
     $passenger->title = $input['passenger_title'];
     $passenger->name = $input['passenger_name'];
     $passenger->sex = $input['passenger_sex'];
     $passenger->age = $input['passenger_age'];
     $passenger->address_line_1 = $input['passenger_address1'];
     $passenger->address_line_2 = $input['passenger_address2'];
     $passenger->address_line_3 = $input['passenger_address3'];
     $passenger->state = $input['passenger_state'];
     $passenger->country = $input['passenger_country'];
     $passenger->occupation = $input['passenger_occupation'];
     $passenger->cabin_id = $input['cabin_form'];
     $passenger->save();
     $reservation = new Reservation();
     $reservation->cruise_id = $input['cruise_form'];
     $reservation->cabin_id = $input['cabin_form'];
     $reservation->customer_id = \Auth::User()->id;
     $reservation->save();
     $cabin = Cabin::where('id', $input['cabin_form'])->first();
     $cabin->occupied = false;
     $cabin->save();
     return view('pages.index')->with('title', 'Welcome');
 }
Exemplo n.º 5
0
 public function updateCruise(Request $request, Cruise $cruise)
 {
     $this->validate($request, ['name' => 'required|max:50', 'price' => 'required|numeric', 'depart_location' => 'required', 'arrive_location' => 'required', 'route_date' => 'required|max:23']);
     $dates = explode(" - ", $request->route_date);
     $depart = DateTime::createFromFormat('m/d/Y', $dates[0])->format('Y-m-d');
     $arrive = DateTime::createFromFormat('m/d/Y', $dates[1])->format('Y-m-d');
     $cruise->name = $request->name;
     $cruise->price = $request->price;
     $cruise->depart_location = $request->depart_location;
     $cruise->arrive_location = $request->arrive_location;
     $cruise->description = $request->description;
     $cruise->type = $request->type;
     $cruise->depart_date = $depart;
     $cruise->arrive_date = $arrive;
     if (Input::hasFile('image')) {
         if (File::exists('uploads/' . $cruise->image)) {
             File::delete('uploads/' . $cruise->image);
         }
         $file = Input::file('image');
         $imagename = 'cruise_' . $cruise->id . '.' . Input::file('image')->getClientOriginalExtension();
         $file->move('uploads', $imagename);
         $cruise->image = $imagename;
     }
     $cabins = Cabin::all();
     $data = [];
     foreach ($cabins as $cabin) {
         $cabinnum = Input::get('cabins.' . $cabin->id);
         if (!empty($cabinnum) || $cabinnum != 0) {
             $data[$cabin->id]['cabin_number'] = $cabinnum;
         }
     }
     $cruise->cabins()->sync($data);
     $cruise->save();
     return redirect('/admin/cruise/' . $cruise->id)->with('status', 'Cruise updated!');
 }
Exemplo n.º 6
0
 public function postNewPromotion(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:50', 'discount' => 'required|numeric|min:1|max:100', 'type' => 'required|numeric|min:1|max:100', 'image' => 'image', 'promo_date' => 'max:23']);
     //create a new promotion
     $promotion = Promotion::create(['name' => $request->name, 'discount' => $request->discount, 'type' => $request->type, 'description' => $request->description]);
     //process dates
     if (!empty($request->promo_date)) {
         $dates = explode(" - ", $request->promo_date);
         $promotion->start_date = DateTime::createFromFormat('m/d/Y', $dates[0])->format('Y-m-d');
         $promotion->end_date = DateTime::createFromFormat('m/d/Y', $dates[1])->format('Y-m-d');
         //check if promotion is activated on create
         if ($dates[0] <= new DateTime("now") && $dates[1] > new DateTime("now")) {
             $promotion_status = 1;
         } else {
             $promotion_status = 0;
         }
     }
     if (Input::hasFile('image')) {
         $file = Input::file('image');
         $imagename = 'promotion_' . $promotion->id . '.' . Input::file('image')->getClientOriginalExtension();
         $file->move('uploads', $imagename);
         $promotion->image = $imagename;
     }
     $promotion->save();
     //attach promotion to selected items
     $cruises = Input::get('cruises');
     $cabins = Input::get('cabins');
     $amenities = Input::get('amenities');
     if (!empty($cruises)) {
         foreach ($cruises as $key => $val) {
             $cruise = Cruise::find($val);
             $cruise->promotion_id = $promotion->id;
             $cruise->save();
         }
     } else {
         if (!empty($cabins)) {
             foreach ($cabins as $key => $val) {
                 $cabin = Cabin::find($val);
                 $cabin->promotion_id = $promotion->id;
                 $cabin->save();
             }
         } else {
             if (!empty($amenities)) {
                 foreach ($amenities as $key => $val) {
                     $amenity = Amenity::find($val);
                     $amenity->promotion_id = $promotion->id;
                     $amenity->save();
                 }
             }
         }
     }
     return redirect('/admin/promotion/' . $promotion->id)->with('status', 'Promotion created!');
 }