Effortlessly Trigger Modals with Session Flash in Laravel

Effortlessly Trigger Modals with Session Flash in Laravel

David Carr

1 min read - 14th Jan, 2025

Laravel Session flash

Here’s a dead simple way of triggering a model to show or anything really from a controller.

From a controller after using session()→flash() to setup a session value

session()->flash('show-update-current-orders-dialog');

Then in a blade file, check for a session matching this value:

@session('show-update-orders-dialog')
   <x-update-order-dialog/>
@endsession

This way you can trigger a model when there is a matching session, this is one time. Once the session has been used if won’t render a second time.

This is incredibly simple but a powerful technique that does not require events or listeners.

0 comments
Add a comment

Copyright © 2025 DC Blog - All rights reserved.