Search code examples
laravellaravel-5laravel-5.3

How to show message only once?


I have profile form with fields, that use should fill.

After submit button I do redirect to another controller(page).

How can I show message there only once? I mean that if user will update again profile, message will not showen more.


Solution

  • Try this, it will only show message one time:

    if($user_update) {
          if(Session::has('update_profile_message') {
              return redirect()->back(); //or wherever you want to redirect
            } else {
              return redirect()->back()->with('update_profile_message', 'Your profile has been updated successfully.');
            }
        }