public function pay_walker() { $walk_id = Input::get('walk_id'); $amount = Input::get('amount'); $walk = Walk::find($walk_id); $walk->is_paid = 1; $walk->amount = $amount; $walk->save(); return Redirect::to('/admin/walk/map/' . $walk_id); }
public function cancel_walk() { if (Request::isMethod('post')) { $walk_id = Input::get('walk_id'); $token = Input::get('token'); $walker_id = Input::get('id'); $validator = Validator::make(array('walk_id' => $walk_id, 'token' => $token, 'walker_id' => $walker_id), array('walk_id' => '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 ($walk = Walk::find($walk_id)) { if ($walk->walker_id == $walker_id) { if ($walk->is_walk_started == 0) { $walk->walker_id = 0; $walk->is_confirmed = 0; $walk->save(); $response_array = array('success' => true); $response_code = 200; } else { $response_array = array('success' => false, 'error' => 'Walk Already Started', 'error_code' => 416); $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; }