Use with method to pass the flash data to view.
return redirect()->intended($this->redirectPath())->with('success','It is successMessage');
Then you can simply call like this in view
{!! $success !!}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using the standard login and my route looks like this:
// Authentication routes...
Route::get('login', 'Auth\AuthController@getLogin');
Route::post('login', 'Auth\AuthController@postLogin');
Route::get('logout', 'Auth\AuthController@getLogout');
I have added sweetalert and my success message looks like this:
flash()->success('Success!', 'You logged in');
I identified that the postLogin & getLogin methods are placed in AuthenticatesUsers.php and they look like this:
protected function handleUserWasAuthenticated(Request $request, $throttles)
{
if ($throttles) {
$this->clearLoginAttempts($request);
}
if (method_exists($this, 'authenticated')) {
return $this->authenticated($request, Auth::user());
}
return redirect()->intended($this->redirectPath());
}
How can I add the success message to that code? I tried with:
flash()->success('Success!', 'User successfully created!');
return redirect()->intended($this->redirectPath());
And some other alternatives but no success. It works for all other sections, like creating articles. Appreciate if someone can help!
@bobeta No need to alter AuthenticatesUsers.php, just add this method to your AuthController.php.
public function authenticated( \Illuminate\Http\Request $request, \App\User $user ) {
flash()->success( 'Logged in', "You have been logged in, {$user->name}" );
return redirect()->intended($this->redirectPath());
}
AuthenticatesUsers.php automatically calls an authenticated() method if it exists and a user was logged in.
If this still does not work, replace flash()->success() with dd() to make sure you actually get there.
Please or to participate in this conversation.