嗨,我试图找出如何显示消息(toastr)成功注册后,我使用laravel 8与急流认证,到目前为止我找不到任何有用的谷歌…顺便说一下,我在RegistredUserController.php
public function store(Request $request,
CreatesNewUsers $creator): RegisterResponse
{
event(new Registered($user = $creator->create($request->all())));
$this->guard->login($user);
return app(RegisterResponse::class);
}
我尝试修改这个代码块,但没有工作…我新的laravel任何建议将非常感激!
所以我会把答案添加到我自己使用jetstream是痛苦的屁股,只是我开始了新的项目与微风,我可以很容易地设置toastr消息注册后。
public function store(Request $request)
{
$request->validate([
'first_name' => ['required', 'string', 'max:255'],
'last_name' => ['required', 'string', 'max:255'],
'username' => ['required', 'string', 'max:255', 'unique:users'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'is_vendor' => ['required', 'integer', 'max:255'],
'password' => ['required', 'confirmed', RulesPassword::defaults()],
]);
$user = User::create([
'first_name' => $request->first_name,
'last_name' => $request->last_name,
'username' => $request->username,
'email' => $request->email,
'is_vendor' => $request->is_vendor,
'password' => Hash::make($request->password),
]);
event(new Registered($user));
//Auth::login($user);
$notification = array(
'message' => 'Registration Completed!',
'alert-type' => 'success'
);
return Redirect()->route('login')->with($notification);
//return redirect(RouteServiceProvider::HOME)->with($notification);
}
使用
return redirect('/dashboard')->with('flash.banner', 'New user register');
https://laravel.com/docs/10.x/session flash-data