public function types()
 {
     $types = ProviderType::all();
     $type_array = array();
     foreach ($types as $type) {
         $data = array();
         $data['id'] = $type->id;
         $data['name'] = $type->name;
         $data['icon'] = $type->icon;
         $data['is_default'] = $type->is_default;
         $data['price_per_unit_time'] = $type->price_per_unit_time;
         $data['price_per_unit_distance'] = $type->price_per_unit_distance;
         $data['base_price'] = $type->base_price;
         array_push($type_array, $data);
     }
     $response_array = array();
     $response_array['success'] = true;
     $response_array['types'] = $type_array;
     $response_code = 200;
     $response = Response::json($response_array, $response_code);
     return $response;
 }
 public function userRequestTrip()
 {
     $date = date("Y-m-d H:i:s");
     $time_limit = date("Y-m-d H:i:s", strtotime($date) - 3 * 60 * 60);
     $owner_id = Session::get('user_id');
     $current_request = Requests::where('owner_id', $owner_id)->where('is_cancelled', 0)->where('created_at', '>', $time_limit)->orderBy('created_at', 'desc')->where(function ($query) {
         $query->where('status', 0)->orWhere(function ($query_inner) {
             $query_inner->where('status', 1)->where('is_walker_rated', 0)->where('confirmed_walker', '>', 0);
         });
     })->first();
     if (!$current_request || $current_request->is_walker_rated == 1) {
         $payments = Payment::where('owner_id', Session::get('user_id'))->count();
         if ($payments != 0) {
             $types = ProviderType::all();
             return View::make('web.userRequestTrip')->with('title', 'Request Trip')->with('types', $types)->with('page', 'request-trip');
         } else {
             $message = "You should add atleast one credit card to request a Trip.";
             $type = "danger";
             return Redirect::to('/user/payments')->with('message', $message)->with('type', $type);
         }
     } else {
         $owner = Owner::find($owner_id);
         $type = ProviderType::find($current_request->type);
         $status = 0;
         if ($current_request->is_completed) {
             $status = 5;
         } elseif ($current_request->is_started) {
             $status = 4;
         } elseif ($current_request->is_walker_arrived) {
             $status = 3;
         } elseif ($current_request->is_walker_started) {
             $status = 2;
         } elseif ($current_request->confirmed_walker) {
             $status = 1;
         } else {
             if ($current_request->status == 1) {
                 $status = 6;
             }
         }
         if ($current_request->confirmed_walker) {
             $walker = Walker::find($current_request->confirmed_walker);
             $rating = DB::table('review_walker')->where('walker_id', '=', $current_request->confirmed_walker)->avg('rating') ?: 0;
             return View::make('web.userRequestTripStatus')->with('title', 'Trip Status')->with('page', 'trip-status')->with('request', $current_request)->with('user', $owner)->with('walker', $walker)->with('type', $type)->with('status', $status)->with('rating', $rating);
         } else {
             return View::make('web.userRequestTripStatus')->with('title', 'Trip Status')->with('page', 'trip-status')->with('request', $current_request)->with('user', $owner)->with('type', $type)->with('rating', 0)->with('status', $status);
         }
     }
 }
 public function providerProfile()
 {
     $walker_id = Session::get('walker_id');
     $user = Walker::find($walker_id);
     $type = ProviderType::all();
     $ps = ProviderServices::where('provider_id', $walker_id)->get();
     return View::make('web.providerProfile')->with('title', 'My Profile')->with('user', $user)->with('type', $type)->with('ps', $ps);
 }
 public function edit_walker()
 {
     $id = Request::segment(4);
     $type = ProviderType::all();
     $provserv = ProviderServices::where('provider_id', $id)->get();
     $success = Input::get('success');
     $walker = Walker::find($id);
     if ($walker) {
         return View::make('edit_walker')->with('title', 'Edit Provider')->with('page', 'walkers')->with('success', $success)->with('type', $type)->with('ps', $provserv)->with('walker', $walker);
     } else {
         return View::make('notfound')->with('title', 'Error Page Not Found')->with('page', 'Error Page Not Found');
     }
 }