Example #1
0
 /**
  *  Getting the data from booking front end form
  *  @param Json
  *  @return void
  * */
 public function bookingSubmitApi(Request $request)
 {
     $booking = new BookingsModel();
     $booking->name = $request->get('name');
     $booking->receive_place = $request->get('receive-place');
     $booking->leaving_place = $request->get('leaving-place');
     $booking->receive_date = $request->get('receive-date');
     $booking->leaving_date = $request->get('leaving-date');
     $booking->price_plan = $request->get('price-plan');
     $booking->promotion_code = $request->get('promotion-code');
     $booking->save();
     return Redirect::to('/');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     /*Validation*/
     $rules = ['client-id' => 'required', 'car-id' => 'required', 'receive-place' => 'required', 'leaving-place' => 'required', 'receive-date' => 'required', 'leaving-date' => 'required', 'price-plan' => 'required', 'promotion-code' => 'required'];
     /*Piping through the validator class*/
     $validator = Validator::make(Input::all(), $rules);
     /*Checking Condition*/
     if ($validator->fails()) {
         return Redirect::to('admin/bookings')->withErrors($validator)->withInput();
     } else {
         /*Store data*/
         $booking = new BookingsModel();
         $booking->client_id = Input::get('client-id');
         $booking->car_id = Input::get('car-id');
         $booking->receive_place = Input::get('receive-place');
         $booking->leaving_place = Input::get('leaving-place');
         $booking->receive_date = Input::get('receive-date');
         $booking->leaving_date = Input::get('leaving-date');
         $booking->price_plan = Input::get('price-plan');
         $booking->promotion_code = Input::get('promotion-code');
         $booking->save();
         /*Redirect with success message*/
         Session::flash('message', 'Booking saved');
         return Redirect::to('admin/bookings');
     }
 }