/** * Delete an existing user. * * @param int $userId * * @return \Illuminate\Http\JsonResponse */ public function delete($userId) { if (!($user = $this->users->findByKey($userId))) { return $this->notFound(); } elseif ($this->users->delete($user)) { return $this->success(); } else { return $this->error('delete failed'); } }
/** * Delete an existing user. * * @param int $userId * * @return \Illuminate\Http\RedirectResponse */ public function delete($userId) { if (!($user = $this->users->findByKey($userId))) { return $this->notFound(); } try { $this->users->delete($user); return $this->redirect('index')->with('success', Lang::get('c::user.delete-success')); } catch (AccessDeniedException $e) { return $this->redirect('edit', [$user->id])->with('error', Lang::get('c::auth.access-denied')); } }