/** * User comments * * @param User $user * @param Request $request * @return \Illuminate\View\View */ public function comments(User $user, Request $request) { $activities = $this->userService->findActivities($user, 'post.comment'); if ($request->has('ajax')) { return $this->respondWithJson($activities, $user, 'ajax.profile.comments'); } return $this->view('profile.comments', compact('user', 'activities')); }
/** * Delete an user * * @param $id * @return \Illuminate\Http\RedirectResponse */ public function delete($id) { if ($page = $this->ensure('admin')) { return $page; } $this->user->deleteById($id); return redirect()->route('admin.users'); }
/** * Handle the event. * * @param UserWasCreated $event * @return void */ public function handle(UserWasCreated $event) { if (!canContact()) { $this->auth->login($event->user); return; } $user = $this->userService->generateConfirmation($event->user); $this->mailer->confirm($user); }
/** * Register a new user * * @param CreateUserRequest $request * @return JsonResponse */ public function register(CreateUserRequest $request) { if (!setting('registration', true)) { return $this->respondWithError(__('For now, no new registrations are allowed!')); } $data = $request->only(['name', 'email', 'password']); try { $user = $this->userService->create($data); } catch (Exception $e) { return response()->json(['general' => 'Internal server error!', 'e' => $e->getMessage()], 422); } return new JsonResponse(['to' => $user->status ? route('home') : route('confirmation')]); }
/** * Store saved settings * * @param Request $request * @param UserService $userService * @return \Illuminate\Http\RedirectResponse */ public function storeSettings(Request $request, UserService $userService) { $this->validate($request, $this->validationRulesForSettings($request)); $fields = $request->only(['name', 'email', 'password', 'avatar', 'language']); if (perm('demo')) { unset($fields['password']); unset($fields['language']); } $userService->updateProfile($this->currentUser, $fields); return redirect()->back(); }