I want to change the time a flash notification is shown.
I have a working laracast flash and that is fine, but the flash coveres about 1/4 of the screen, so I only want it forabout 2sek and not like 10sek as it is now. I don't know where to start. Is there such a function?
This is the flash
if ( ! function_exists('flash')) {
/**
* Arrange for a flash message.
*
* @param string|null $message
* @param string $level
* @return \Laracasts\Flash\FlashNotifier
*/
function flash($message = null, $level = 'info')
{
$notifier = app('flash');
if ( ! is_null($message)) {
return $notifier->message($message, $level);
}
return $notifier;
}
}
This is where it is called
if ($cartItem->save()) {
flash(trans( 'alerts.cart_added'), 'success')->important();
return back();
There is a simple example in the GitHub page of the package Hiding Flash Message
From the document,
Write a simple bit of JavaScript. For example, using jQuery, you might add the following snippet just before the closing tag.
<script> $('div.alert').not('.alert-important').delay(3000).fadeOut(350); </script>
This will find any alerts - excluding the important ones, which should remain until manually closed by the user - wait three seconds, and then fade them out.
So for your case you just need to only target the specific important class like:
(if you are using jQuery)
$('.alert-important').delay(3000).fadeOut(350);