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