['required', 'email'], 'password' => 'required'"> How to call specific data from database in Laravel and add to my message-PHP Chinese Network Q&A
How to call specific data from database in Laravel and add to my message
P粉111227898
P粉111227898 2023-08-06 20:00:44
0
1
495

如何将特定数据的名称包含在我的返回信息消息中?

UserController:

public function process(Request $request){ $validated = $request->validate([ "email" => ['required', 'email'], 'password' => 'required' ]); if(auth()->attempt($validated)){ $request->session()->regenerate(); return redirect('/')->with('information-message', 'Welcome Back!'); } return redirect('login')->with('failed-message', 'Login Failed. Please Try Again!'); }

information-message.blade.php:

@if (session()->has('information-message'))  @endif

如果登录成功:我希望输出变成欢迎回来!(登录的用户的姓名)。

P粉111227898
P粉111227898

reply all (1)
P粉403804844

You can use the Auth facade to get the current user.

Auth::user()

Depending on your situation

return redirect('/')->with('information-message', 'Welcome Back! '.Auth::user()->name);
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!