jjudge's avatar

Should flash messages now go through Notifications?

So, we have traditional flash messages that allows the server to notify the current user of the result of an action on the next page load. We also have Notifications (L5.6/5.7) that can be be used to notify a user of the result of a server-side action. Are these now one and the same thing?

Instead of multiple ways of notifying the user of a result, is it possible just to use Notifications for ALL notification messages and use a "flash" channel to flash messages to the current user? It seems like a more abstract way to handle it, and would allow the channel to be switched to other methods of notification as the application is updated, without having to go through the code and change the method of creating the flash messages. The flash channel, I guess, would only be usable in a controller, since it would need access to the session.

Or am I trying to fit a square peg into a round hole?

0 likes
1 reply
martinbean's avatar

@consil Flash messages to me are synchronous. They are—as you say—tied to a HTTP request. If you queue something, you’ll still want to display a flash message:

SomeLongRunningJob::dispatch();

return redirect()
    ->to('somewhere')
    ->withSuccess('Job has been submitted.');

In the above example, it doesn’t make sense to move the flash message to the job. The user needs to know on the next page if the job’s been dispatched or not; not when the job’s completed.

By all means, still send a notification when the job’s finished (that can be delivered via SMS, email or whatever), but I’d still keep creating flash messages in your controllers.

Please or to participate in this conversation.