Um pacote leve para enviar mensagens flash em aplicativos Laravel. Este pacote suporta apenas uma única mensagem flash de cada vez, e a mensagem flash é exibida no formato de uma notificação de brindes
composer require bkstar123/flashing
Depois disso, você precisa publicar os ativos do pacote:
php artisan vendor:publish --provider="Bkstar123FlashingFlashingServiceProvider"
Ele copiará um elemento de visualização da lâmina para resources/views/vendor/bkstar123_flashing/flashing.blade.php . Você é livre para personalizar esse elemento de exibição. Além disso, ele copiará os arquivos JavaScript do pacote para public/js/vendor/bkstar123)handling/*.js
a) em vista
Em exibição ou layout mestre, basta incluir o elemento de exibição do pacote com @include('bkstar123_flashing::flashing')
b) nos métodos controladores
Fora da caixa, o pacote fornece o seguinte conjunto de ferramentas para exibir uma mensagem:
Bkstar123FlashingFacadesFlashing . Como alternativa, você pode usar seu alias Flashingflashing()O pacote suporta os seguintes tipos de mensagens piscantes:
Exemplo :
<?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 os métodos success() | error() | warning() | info() pode ser encadeado após message() e também encadeado por important(), timeout() & position() . Na final, você deve sempre anexar flash() à corrente.
Nota : flashing('hello world') <=> Flashing::message('hello world')