public function update(Request $request, $id) { $validator = \Validator::make($request->all(), ['id' => 'required', 'email' => 'required|email|unique:users', 'name' => 'required', 'password' => 'min:6']); if ($validator->fails()) { throw new StoreResourceFailedException('Could not able to update user.', $validator->errors()); } $user = User::findorfail($id); $user->email = $request->get('email'); $user->name = $request->get('name'); if ($request->get('password')) { $user->password = Hash::make($request->get('password')); } if ($user->save()) { return $this->response->array(['message' => 'User has been updated successfully', 'status' => 200]); } else { return $this->response->array(['message' => 'Unable to update user. Please try again', 'status' => 200]); } }
/** * Parse the includes. * * @param \Dingo\Api\Http\Request $request * * @return void */ public function parseFractalIncludes(Request $request) { $includes = $request->get($this->includeKey); if (!is_array($includes)) { $includes = array_filter(explode($this->includeSeparator, $includes)); } $this->fractal->parseIncludes($includes); }