P粉6048485882023-08-14 12:51:02
Try this
session()->flash('msg', ['text' => $msg, 'color' => $color]);
In blade template
<div class="col-sm-12 col-xl-12"> @if (session()->has('msg')) <h5 style="color: {{ session('msg.color') }}">{{session('msg.text') }}</h5> @endif </div>
In this code, I made sure to include the correct imports, use the correct method for data insertion, and use the flash() method instead of the put() method to temporarily store the message in the session. In addition, the color of the message is also stored in the session for better control over styling.
Alternatively, you can try binding it using the WITH
method.
return back()->with('msg', 'Your message');
You can use redirect()
redirect()->route()
and other methods.
Also, please read the docs carefully, you will get a lot of ideas from it.