Level 73
I your controller methods you can do this
return redirect('dashboard')->with('success', 'Profile updated!');
You should use {{ }} instead of {!! !!}
2 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have controller and function like below
class UserController extends Controller
{
public function index(){
$title = trans('app.users');
$users = User::orderBy('first_name', 'asc')->paginate(20);
$users_count = User::count();
return view('admin.users', compact('title', 'users', 'users_count'));
}
}
I have a blade template named flash_msg.blade.php which has below content.
@if(session('success'))
<div class="alert alert-success">
{!! session('success') !!}
</div>
@endif
@if(session('error'))
<div class="alert alert-danger">
{!! session('error') !!}
</div>
I included below code in my blade template.
@include('admin.flash_msg')
How can I use this ? Which code should I write in controller to get the result of Flash Message ?
Thanks
Please or to participate in this conversation.