/** * Update the specified pet in storage. * * @param int $id * @return Response */ public function update($id) { $pet = Pet::findOrFail($id); $data = Input::all(); $data['user_id'] = Confide::user()->id; $validator = Validator::make($data, Pet::$rules); $response = []; $response['data'] = $data; if ($validator->fails()) { $response['success'] = false; $response['errors'] = $validator->errors(); if (Request::ajax()) { return Response::json($response); } else { return Redirect::back()->withErrors($validator->errors()); } } $pet->update($data); $response['success'] = true; $response['errors'] = []; if (Request::ajax()) { return Response::json($response); } else { return Redirect::action('UsersController@showProfile', Confide::user()->id); } }