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')