json(User::create([ 'name' => $request->name, 'email' => $request->email, 'password' => Hash::make($request->password), ])); } /** * Update a user. * * @param UserUpdateRequest $request * @param User $user * * @throws \RuntimeException * * @return \Illuminate\Http\JsonResponse */ public function update(UserUpdateRequest $request, User $user) { $data = $request->only('name', 'email'); if ($request->password) { $data['password'] = Hash::make($request->password); } return response()->json($user->update($data)); } /** * Delete a user. * * @param User $user * * @throws \Exception * @throws \Illuminate\Auth\Access\AuthorizationException * * @return \Illuminate\Http\JsonResponse */ public function destroy(User $user) { $this->authorize('destroy', $user); return response()->json($user->delete()); } }