我如何处理 laravel 中被阻止的用户
How can I handle Blocked Users in laravel
我需要帮助。你能指导我如何向被阻止的用户显示他的帐户已被阻止的消息。我只是把他渲染到 post 页。但我想向他显示一些消息,表明您的帐户已被阻止,或者像我们在验证消息中所做的那样。请简单指导。
public函数登录(请求$request)
{
$用户名= $request->用户名;
$user = User::where('username',$username)->first();
// return $user;
// return $user->id;
if($user != null){
$active = Activation::whereUserId($user->id)->first();
if($active->completed==0){
return redirect('/posts');
}
您需要使用 session。一种方法:
return redirect('posts')->with('error', 'Your account is blocked');
并且在重定向后的视图中:
@if (session('error'))
{{ session('error') }}
@endif
如果您不想重定向用户,只需将变量传递到视图中即可:
return view('login.form', ['notActivated' => $active->completed === 0])
并且在视图中:
@if ($notActivated)
Your account is blocked
@endif
我需要帮助。你能指导我如何向被阻止的用户显示他的帐户已被阻止的消息。我只是把他渲染到 post 页。但我想向他显示一些消息,表明您的帐户已被阻止,或者像我们在验证消息中所做的那样。请简单指导。
public函数登录(请求$request) { $用户名= $request->用户名;
$user = User::where('username',$username)->first();
// return $user;
// return $user->id;
if($user != null){
$active = Activation::whereUserId($user->id)->first();
if($active->completed==0){
return redirect('/posts');
}
您需要使用 session。一种方法:
return redirect('posts')->with('error', 'Your account is blocked');
并且在重定向后的视图中:
@if (session('error'))
{{ session('error') }}
@endif
如果您不想重定向用户,只需将变量传递到视图中即可:
return view('login.form', ['notActivated' => $active->completed === 0])
并且在视图中:
@if ($notActivated)
Your account is blocked
@endif