Home > Software design >  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?

Time:07-19

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  role="alert">
                    <strong>{{ session()->get('success-login') }}</strong>
                    <button type="button"  data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
            @endif

CodePudding user response:

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');
        }
    });
}
  • Related