/**
  * @param Request $request
  *
  * @return \Illuminate\View\View
  */
 public function second(Request $request)
 {
     $passengers = Session::get('passengers');
     $trip_id = Session::get('trip_id');
     $trip = Trip::find($trip_id);
     $user_id = Auth::user()->get()->id;
     //		if(!$this->checkIfReportingTimeIsValid($passengers, $request->except(['cash_card', 'speed_banking', 'reserve', 'cash_card_code', 'speed_banking_code']), $trip_id))
     //		{
     //			return redirect()->back()
     //				->withErrors("Your Reporting Time should be {$trip->departure_time} time")
     //				->withInput();
     //		}
     $ticketData = $request->except(['cash_card', 'speed_banking', 'reserve', 'cash_card_code', 'speed_banking_code']);
     Session::put('data', $ticketData);
     if ($request->has('cash_card')) {
         $code = strtoupper($request->cash_card_code);
         if ($this->cashCard->checkIfCashCardCodeIsValid($code, $trip_id, $passengers)) {
             $status = "paid";
             $number = true;
             $paid = true;
             $input = $this->insertIntoDatabase($passengers, $request->all(), $user_id, $trip_id, $status, $number, $paid);
             Session::put('b_c_data', $ticketData);
             Session::put('b_c_passengers', $passengers);
             Session::put('b_c_trip_id', $trip_id);
             Session::put('b_c_input', $input);
             return redirect()->route('success');
         } else {
             return redirect()->back()->withErrors('There was a problem processing the payment')->withInput();
         }
     } elseif ($request->has('speed_banking')) {
         $code = strtoupper($request->speed_banking_code);
         if ($this->cashCard->checkIfCashCardCodeIsValid($code, $trip_id, $passengers)) {
             dd('paying speedBanking');
             $status = "paid";
             $number = true;
             $paid = true;
             $input = $this->insertIntoDatabase($passengers, $request->all(), $user_id, $trip_id, $status, $number, $paid);
             Session::put('b_s_data', $ticketData);
             Session::put('b_s_passengers', $passengers);
             Session::put('b_s_trip_id', $trip_id);
             return redirect()->route('success');
         } else {
             return redirect()->back()->withErrors('There was a problem processing the payment')->withInput();
         }
     } else {
         $number = false;
         $paid = false;
         $status = 'reserved';
         $this->insertIntoDatabase($passengers, $request->all(), $user_id, $trip_id, $status, $number, $paid);
         Session::put('r_data', $ticketData);
         Session::put('r_passengers', $passengers);
         Session::put('r_trip_id', $trip_id);
         //			dd($data);
         return redirect()->route('trip-reserved');
     }
 }
 /**
  * @param Request $request
  *
  * @return $this|\Illuminate\View\View
  */
 public function pay_reserve_booking_now(Request $request)
 {
     $booking = Booking::find($request->booking_id);
     $trip = Trip::find($booking->trip_id);
     $trip_id = $trip->id;
     $passengers = 1;
     $travel_company_id = $trip->travel_company_id;
     if ($request->has('cashcard_code')) {
         $code = strtoupper($request->cashcard_code);
         if ($this->cashCard->checkIfCashCardCodeIsValid($code, $trip->id, $passengers)) {
             $status = "paid";
             $booking->status = $status;
             $booking->ticket_number = rand() . time();
             $booking->save();
             Payment::create(['trip_id' => $booking->trip->id, 'amount' => $booking->trip->fare, 'user_id' => Auth::user()->get()->id, 'booking_id' => $booking->id, 'travel_company_id' => $travel_company_id]);
             $user = Auth::user()->get();
             //				$mail = view('mails.ticket')->render();
             Session::put('r_b_c_data', $booking);
             Session::put('r_b_c_passengers', $passengers);
             Session::put('r_b_c_trip_id', $trip_id);
             //				Mail::send('mails.new', ['user' => $user], function ($m) use ($user) {
             //		            $m->to($user->email, $user->name)->subject('Passenger name booking detail');
             //		        });
             return redirect()->route('reserved-trip-paid');
         } else {
             return redirect()->back()->withErrors('There was a problem processing the payment');
         }
     } elseif ($request->has('speedBanking_code')) {
         $code = $request->speed_banking_code;
         if ($this->cashCard->checkIfCashCardCodeIsValid($code, $trip->id, $passengers)) {
             dd('paying speedBanking');
             $status = "paid";
             //				$this->insert($passengers, $request->all(), $user_id, $trip_id, $status);
             return view('payment.success');
         } else {
             return redirect()->back()->withErrors('There was a problem processing the payment');
         }
     }
 }