public function getActivation($id, $activation_code) { // if user has logged in but has the id not equals $id, the activation will not process // due to the middleware 'guest' applied to this controller in the constructor $user = User::findOrFail($id); $active = $user->activation_code == $activation_code; if ($active) { $user->active = true; $user->save(); } $this->theme->title(trans('pages.account_activate_title')); $this->theme->description(trans('pages.account_activate_title')); return view($this->themePage('auth.activate'), ['active' => $active, 'url' => $this->is_auth ? redirectUrlAfterLogin($this->auth_user) : homeUrl('auth/login')]); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Request $request, $id) { $user = User::findOrFail($id); $redirect_url = adminUrl('users'); $rdr = $request->session()->pull(AppConfig::KEY_REDIRECT_URL, ''); if (!empty($rdr)) { $redirect_url = $rdr; } if ($user->hasRole('owner')) { return redirect($redirect_url)->withErrors([trans('error._cannot_delete', ['reason' => trans('error.is_role_owner')])]); } return $user->delete() === true ? redirect($redirect_url) : redirect($redirect_url)->withErrors([trans('error.database_delete')]); }