laravelfortifylaravel-fortify

how to create a flash message when a user successfully logged in on fortify?


how to create a flash message when a user successfully logged in on fortify? later in the blade view I just need to call using

            @if(session()->has('success-login'))
                <div class="alert alert-info alert-dismissible fade show" role="alert">
                    <strong>{{ session()->get('success-login') }}</strong>
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
            @endif

Solution

  • According to laravel document you can use the with method and redirect to your custom page with a flash message.

    public function register()
    {
        $this->app->instance(LoginResponse::class, new class implements LoginResponse {
            public function toResponse($request)
            {
                return redirect('/')->with('success-login', 'message');
            }
        });
    }