flashing
1.0.0
輕巧的包裝,可在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
a)看見
在視圖或主佈局中,只需將軟件包的視圖元素與@include('bkstar123_flashing::flashing')一起包含
b)在控制器方法中
開箱即用,軟件包為您提供以下工具集,用於刷新消息:
Bkstar123FlashingFacadesFlashing立面。另外,您可以使用其別名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')