Un paquete liviano para enviar mensajes flash en aplicaciones Laravel. Este paquete solo admite un solo mensaje flash a la vez, y el mensaje flash se muestra en el formato de una notificación de tostadas
composer require bkstar123/flashing
Después de eso, debe publicar los activos del paquete:
php artisan vendor:publish --provider="Bkstar123FlashingFlashingServiceProvider"
Copiará un elemento de vista de cuchilla a resources/views/vendor/bkstar123_flashing/flashing.blade.php de su aplicación. Usted es libre de personalizar este elemento de vista. Además, copiará los archivos JavaScript del paquete al public/js/vendor/bkstar123)handling/*.js
a) A la vista
A la vista o el diseño maestro, solo incluya el elemento de vista del paquete con @include('bkstar123_flashing::flashing')
b) En los métodos del controlador
Fuera de la caja, el paquete le proporciona el siguiente conjunto de herramientas para flashear un mensaje:
Bkstar123FlashingFacadesFlashing . Alternativamente, puede usar su alias Flashingflashing()El paquete admite los siguientes tipos de mensajes intermitentes:
Ejemplo :
<?php
// Flash a info-typed message by default
Flashing:: message ( ' Welcome to the home page ' )
-> flash ();
flashing ( ' Welcome to the home page ' )
-> flash ();
// Flash a success-typed message
Flashing:: message ( ' Welcome to the home page ' )
-> success ()
-> flash ();
flashing ( ' Welcome to the home page ' )
-> success ()
-> flash ();
// Flash a message and mark it as important i.e it will not disappear until being dismissed by yourself
Flashing:: message ( ' Important message ' )
-> important ()
-> flash ();
flashing ( ' Important message ' )
-> important ()
-> flash ();
// Specify the miliseconds for timing out the flash message
// The given timeout will be ignored if you mark the flash message as important
Flashing:: message ( ' This message will disappear after 3 seconds ' )
-> timeout ( 3000 )
-> flash ();
flashing ( ' This message will disappear after 3 seconds ' )
-> timeout ( 3000 )
-> flash ();
// Specify the location of the flash message, it can be either top-right or bottom-right
Flashing:: message ( ' I will be on the top-right of your screen ' )
-> position ( ' top ' )
-> flash ();
flashing ( ' I will be on the top-right of your screen ' )
-> position ( ' top ' )
-> flash (); Todos los métodos success() | error() | warning() | info() puede ser encadenado después message() así como encadenado por important(), timeout() & position() . En la final, siempre debe agregar flash() a la cadena.
Nota : flashing('hello world') <=> Flashing::message('hello world')