public function providerTripDetail() { $id = Request::segment(3); $walker_id = Session::get('walker_id'); $request = Requests::find($id); $request_services = RequestServices::where('request_id', $request->id)->first(); if ($request->confirmed_walker == $walker_id) { $locations = WalkLocation::where('request_id', $id)->orderBy('id')->get(); $start = WalkLocation::where('request_id', $id)->orderBy('id')->first(); $end = WalkLocation::where('request_id', $id)->orderBy('id', 'desc')->first(); $map = "https://maps-api-ssl.google.com/maps/api/staticmap?size=249x249&style=feature:landscape|visibility:off&style=feature:poi|visibility:off&style=feature:transit|visibility:off&style=feature:road.highway|element:geometry|lightness:39&style=feature:road.local|element:geometry|gamma:1.45&style=feature:road|element:labels|gamma:1.22&style=feature:administrative|visibility:off&style=feature:administrative.locality|visibility:on&style=feature:landscape.natural|visibility:on&scale=2&markers=shadow:false|scale:2|icon:http://d1a3f4spazzrp4.cloudfront.net/receipt-new/marker-start@2x.png|{$start->latitude},{$start->longitude}&markers=shadow:false|scale:2|icon:http://d1a3f4spazzrp4.cloudfront.net/receipt-new/marker-finish@2x.png|{$end->latitude},{$end->longitude}&path=color:0x2dbae4ff|weight:4"; foreach ($locations as $location) { $map .= "|{$location->latitude},{$location->longitude}"; } $start_location = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?latlng={$start->latitude},{$start->longitude}"), TRUE); $start_address = $start_location['results'][0]['formatted_address']; $end_location = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?latlng={$end->latitude},{$end->longitude}"), TRUE); $end_address = $end_location['results'][0]['formatted_address']; $owner = Owner::find($request->owner_id); $owner_review = DogReview::where('request_id', $id)->first(); if ($owner_review) { $rating = round($owner_review->rating); } else { $rating = 0; } /* $var = Keywords::where('id', 4)->first(); */ /* $currency = Keywords::where('id', 5)->first(); */ return View::make('web.providerTripDetail')->with('title', 'My ' . Config::get('app.generic_keywords.Trip') . 's')->with('request', $request)->with('request_services', $request_services)->with('start_address', $start_address)->with('end_address', $end_address)->with('currency', Config::get('app.generic_keywords.Currency'))->with('start', $start)->with('end', $end)->with('map_url', $map)->with('owner', $owner)->with('rating', $rating); } else { echo "false"; } }
public function set_dog_rating() { if (Request::isMethod('post')) { $comment = Input::get('comment'); $request_id = Input::get('request_id'); $rating = Input::get('rating'); $token = Input::get('token'); $walker_id = Input::get('id'); $validator = Validator::make(array('comment' => $comment, 'request_id' => $request_id, 'rating' => $rating, 'token' => $token, 'walker_id' => $walker_id), array('comment' => 'required', 'request_id' => 'required|integer', 'rating' => 'required|integer', 'token' => 'required', 'walker_id' => 'required|integer')); if ($validator->fails()) { $error_messages = $validator->messages()->all(); $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages); $response_code = 200; } else { $is_admin = $this->isAdmin($token); if ($walker_data = $this->getWalkerData($walker_id, $token, $is_admin)) { // check for token validity if (is_token_active($walker_data->token_expiry) || $is_admin) { // Do necessary operations if ($request = Requests::find($request_id)) { if ($request->confirmed_walker == $walker_id) { if ($request->is_dog_rated == 0) { $owner = Owner::find($request->owner_id); $dog_review = new DogReview(); $dog_review->request_id = $request_id; $dog_review->walker_id = $walker_id; $dog_review->rating = $rating; $dog_review->owner_id = $owner->id; $dog_review->comment = $comment; $dog_review->save(); $request->is_dog_rated = 1; $request->save(); $response_array = array('success' => true); $response_code = 200; } else { $response_array = array('success' => false, 'error' => 'Already Rated', 'error_code' => 409); $response_code = 200; } } else { $response_array = array('success' => false, 'error' => 'Walk ID doesnot matches with Walker ID', 'error_code' => 407); $response_code = 200; } } else { $response_array = array('success' => false, 'error' => 'Walk ID Not Found', 'error_code' => 408); $response_code = 200; } } else { $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405); $response_code = 200; } } else { if ($is_admin) { $response_array = array('success' => false, 'error' => 'Walker ID not Found', 'error_code' => 410); } else { $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406); } $response_code = 200; } } } $response = Response::json($response_array, $response_code); return $response; }
public function delete_review_owner() { $id = Request::segment(4); $walker = DogReview::where('id', $id)->delete(); return Redirect::to("/admin/reviews"); }
public function set_dog_rating() { if (Request::isMethod('post')) { $comment = ""; if (Input::has('comment')) { $comment = Input::get('comment'); } $request_id = Input::get('request_id'); $rating = 0; if (Input::has('rating')) { $rating = Input::get('rating'); } $token = Input::get('token'); $walker_id = Input::get('id'); $validator = Validator::make(array('request_id' => $request_id, 'token' => $token, 'walker_id' => $walker_id), array('request_id' => 'required|integer', 'token' => 'required', 'walker_id' => 'required|integer')); /* $var = Keywords::where('id', 1)->first(); */ if ($validator->fails()) { $error_messages = $validator->messages()->all(); $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages); $response_code = 200; } else { $is_admin = $this->isAdmin($token); if ($walker_data = $this->getWalkerData($walker_id, $token, $is_admin)) { // check for token validity if (is_token_active($walker_data->token_expiry) || $is_admin) { // Do necessary operations if ($request = Requests::find($request_id)) { if ($request->confirmed_walker == $walker_id) { if ($request->is_dog_rated == 0) { $owner = Owner::find($request->owner_id); $dog_review = new DogReview(); $dog_review->request_id = $request_id; $dog_review->walker_id = $walker_id; $dog_review->rating = $rating; $dog_review->owner_id = $owner->id; $dog_review->comment = $comment; $dog_review->save(); $request->is_dog_rated = 1; $request->save(); if ($rating) { if ($owner = Owner::find($request->owner_id)) { $old_rate = $owner->rate; $old_rate_count = $owner->rate_count; $new_rate_counter = $owner->rate_count + 1; $new_rate = ($owner->rate * $owner->rate_count + $rating) / $new_rate_counter; $owner->rate_count = $new_rate_counter; $owner->rate = $new_rate; $owner->save(); } } $response_array = array('success' => true); $response_code = 200; } else { $response_array = array('success' => false, 'error' => 'Already Rated', 'error_code' => 409); $response_code = 200; } } else { /* $response_array = array('success' => false, 'error' => 'Service ID doesnot matches with ' . $var->keyword . ' ID', 'error_code' => 407); */ $response_array = array('success' => false, 'error' => 'Service ID doesnot matches with ' . Config::get('app.generic_keywords.Provider') . ' ID', 'error_code' => 407); $response_code = 200; } } else { $response_array = array('success' => false, 'error' => 'Service ID Not Found', 'error_code' => 408); $response_code = 200; } } else { $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405); $response_code = 200; } } else { if ($is_admin) { /* $response_array = array('success' => false, 'error' => '' . $var->keyword . ' ID not Found', 'error_code' => 410); */ $response_array = array('success' => false, 'error' => '' . Config::get('app.generic_keywords.Provider') . ' ID not Found', 'error_code' => 410); } else { $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406); } $response_code = 200; } } } $response = Response::json($response_array, $response_code); return $response; }