Легкий пакет для отправки флэш -сообщений в приложениях Laravel. Этот пакет поддерживает только одно флэш -сообщение за раз, и флэш -сообщение отображается в формате уведомления о тосте.
composer require bkstar123/flashing
После этого вам нужно опубликовать активы пакета:
php artisan vendor:publish --provider="Bkstar123FlashingFlashingServiceProvider"
Он скопирует элемент просмотра лезвия в resources/views/vendor/bkstar123_flashing/flashing.blade.php . Вы можете настроить этот элемент просмотра. Кроме того, он скопирует файлы JavaScript в пакете в public/js/vendor/bkstar123)handling/*.js
а) Ввиду
В виде или мастер -макета, просто включите элемент просмотра пакета с @include('bkstar123_flashing::flashing')
б) в методах контроллера
Из коробки пакет предоставляет вам следующий набор инструментов для прошивки сообщения:
Bkstar123FlashingFacadesFlashing Facade. В качестве альтернативы, вы можете использовать его псевдоним, Flashingflashing() вспомогательная функцияПакет поддерживает следующие типы мигающих сообщений:
Пример :
<?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 (); Все методы success() | error() | warning() | info() может быть прикован в цепочке после message() , а также прикованной в цепочках с помощью important(), timeout() & position() . В финале вы всегда должны добавлять flash() к цепочке.
Примечание : flashing('hello world') <=> Flashing::message('hello world')