I want to put an alert message on my Listener:
if ($type == '-'){
if ($balance < $amo) {
flash()->overlay('Warning!', 'Amount is higher than Balance.', 'warning');
} else {
$wallet->users()->updateExistingPivot($uid, ["balance" => ($balance - $amo)]);
}
} else {
$wallet->users()->updateExistingPivot($uid, ["balance" => ($balance + $amo)]);
}
But this flash() does not seem to be working. I mean, it does not show the message Amount is higher than Balance..
So how to print this message properly via the Listener?
Event should be "sideeffect" of your primary action.
So default meaning is, that event should not have direct response.
I think you should rethink your code design.
ANYWAY
You can do that by putting message into session via your event. This is strongly unrecommended (at least by me). But at least, take care of deleting this message from session after usage.
You have your event emitter in try/catch. If try fits in, you will flash message. If it will not fit in, you will throw an error in your listener and catch it. There you can flash another message. Again, I do not recommend even this solution
EXAMPLE
And run it like this: