5

I used Laravel Breeze in Laravel Nova to generate scaffold code for registering a user.

When a user go to registering an account, he goes to the /register route.

All the Breeze code is working.

But when account is created, it redirect to RouteServiceProvider::HOME

class RegisteredUserController extends Controller
{
public function store(Request $request)
    {
        $request->validate([
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'confirmed', Rules\Password::defaults()],
        ]);

        $user = User::create([
            'name' => $request->name,
            'email' => $request->email,
            'password' => Hash::make($request->password),
        ]);

        event(new Registered($user));

//        Auth::login($user);
//        Session::flash('message', __("activation_email_sent"));
        $request->session()->flash('warning', 'You do not have permission to access that page.');

        return redirect(RouteServiceProvider::HOME);
}

I change RouteServiceProvider::HOME to match /nova/login, but it doesn't send any toast message, so it is confusing for the user.

I would like to send a message saying the basic stuff : "we sent you a verification email, check you spam, etc."

Thing is I tried a lot the following options and none is working.

Session::flash('message', "The Message"));
$request->session()->flash('warning', 'The Message');
return redirect(RouteServiceProvider::HOME)->with('status', 'The Message!');
redirect(RouteServiceProvider::HOME)->withErrors(['msg', 'The Message']);

How should I make the green message appear ?

Juliatzin
  • 18,455
  • 40
  • 166
  • 325

0 Answers0