user1157885
user1157885

Reputation: 2069

Laravel Authenticate middleware flash message

In my auth middleware I have the following code:

        if (! Auth::user()->enabled) {
            Auth::logout();
            // $request->session()->flash('Test', 'Test');
            // return redirect()->route('site::home');

            return redirect()->route('site::home')->withFlash('Test');
        }

I'm trying to redirect the user back to the login page with a flash message but whenever I look into the session() there's no flash message.

What am I doing wrong? it feels like i've tried every variation of a flash message and none of it seems to work

Upvotes: 0

Views: 2871

Answers (2)

Cristhian Coaquira
Cristhian Coaquira

Reputation: 49

Try this instead

return redirect()->route('route_name')->with('custom_key', 'Custom Message');

Upvotes: 1

Huzaib Shafi
Huzaib Shafi

Reputation: 1138

return redirect()->route('site::home')->flash('This is a message!');

OR

return \Redirect::back()->withWarning( 'Message you want show in View' );

Upvotes: 1

Related Questions