public function create(Request $request)
 {
     $sub_locations = Sub_location::where('main_sub_location', true)->get();
     $direction_id = $request->input('direction_id');
     $this_income = Income_list::with('car_type')->where('direction_id', $direction_id)->where('car_type_id', $request->input('car_type_id'))->where('income_type_id', 1)->whereNull('user_id')->firstOrFail();
     $incomes = Income_list::with('car_type')->where('income_type_id', 1)->whereNull('user_id')->where('direction_id', $direction_id)->get();
     $cars = Car_type::with('income_list')->whereHas('income_list', function ($query) use($direction_id) {
         $query->where('direction_id', $direction_id)->where('income_type_id', 1)->whereNull('user_id');
     })->get();
     $direction = Direction::with('start', 'via1', 'via2', 'via3', 'end')->find($direction_id);
     $old = $request->old();
     $variables = array('car_type_id' => $request->input('car_type_id'), 'pickup_date_part' => $request->input('pickup_date_part'));
     JavaScript::put(['variables' => $variables, 'old' => $old, 'sub_locations' => $sub_locations, 'this_income' => $this_income, 'incomes' => $incomes, 'cars' => $cars, 'direction' => $direction, 'csrf_token' => csrf_token()]);
     return view('reservation.create');
 }
 public function edit($booking_id)
 {
     $booking = Booking::with('comment.comment_type', 'comment.role.user', 'comment.role.role_type', 'change.change_type', 'change.user', 'car_type', 'role.user', 'role.role_type', 'income.income_type', 'outcome.outcome_type', 'route_point.location', 'route_point.sub_location', 'route_point.address')->with(array('route_point' => function ($query) {
         $query->orderBy('order', 'ASC');
     }))->findOrFail($booking_id);
     $car_types = Car_type::get();
     $role_types = Role_type::get();
     $income_types = Income_type::get();
     $outcome_types = Outcome_type::get();
     $locations = Location::get();
     $sub_locations = Sub_location::get();
     $addresses = Address::get();
     JavaScript::put(['addresses' => $addresses, 'booking' => $booking, 'car_types' => $car_types, 'income_types' => $income_types, 'locations' => $locations, 'outcome_types' => $outcome_types, 'role_types' => $role_types, 'sub_locations' => $sub_locations, 'csrf_token' => csrf_token()]);
     return view('booking.edit');
 }