bindeveloperz / alert
此包已被弃用且不再维护。未建议替代包。
受laracast/flash启发的Laravel错误消息提示包。
1.0.0
2018-04-09 05:58 UTC
This package is not auto-updated.
Last update: 2020-01-28 06:06:03 UTC
README
受laracast alert package启发
为您的Laravel应用程序提供简单闪存消息(不要用于生产应用程序。)
此Composer包为您的Laravel 5应用程序提供优化的Twitter Bootstrap 4闪存消息设置。
安装
首先,通过Composer引入包。
composer require bindeveloperz/alert
接下来,如果您使用Laravel 5.5,请将服务提供者在您的 config/app.php
文件中包含。
'providers' => [ Bindeveloperz\Alert\AlertServiceProvider::class, ];
用法
在您的控制器中,在执行重定向之前,调用 flash()
函数。
public function store() { flash('Welcome Aboard!'); return home(); }
您还可以这样做
flash('Message')->success()
:将闪存主题设置为 "成功"。flash('Message')->error()
:将闪存主题设置为 "危险"。flash('Message')->warning()
:将闪存主题设置为 "警告"。
将此消息闪存到会话中后,您现在可以在视图(s)中显示它。由于闪存消息和覆盖层非常常见,我们提供了一套现成的模板来帮助您开始。您可以自由使用 - 以及根据您的需要修改 - 这个模板。
@include('flash::message')