Effortlessly Trigger Modals with Session Flash in Laravel

David Carr

Laravel Framework

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

From a controller use session()→flash() to setup a session value

session()->flash('show-update-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.

Read articles directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Copyright © 2006 - 2025 DC Blog - All rights reserved.