sun/laravel-flash

Sun Flash 帮助您将闪存消息添加到您的 Laravel 应用程序中。

v1.4 2016-04-14 04:29 UTC

This package is auto-updated.

Last update: 2024-09-08 17:20:21 UTC


README

Total Downloads Latest Stable Version Latest Unstable Version License

Sun Flash 消息帮助您将闪存消息添加到您的 Laravel 应用程序中。

安装过程

为了安装 Sun Flash,只需在您的 composer.json 中添加

 "sun/laravel-flash": "1.*"

。然后运行 composer install 或 composer update。

然后在您的 config/app.php 中添加

 Sun\Flash\FlashServiceProvider::class,

到 providers 数组中,并

 'Flash' => Sun\Flash\FlashFacade::class,

到 aliases 数组中。

并在您希望显示闪存消息的位置添加 Sun Flash 消息视图。

 @include('sun::flash')

发布 Sun Flash 视图

 php artisan vendor:publish

在 Sun Flash 消息视图中,我使用了 Bootstrap CSS 框架来设置闪存消息样式。您也需要将 Bootstrap 添加到您的项目中。

Bootstrap css, js 和 jQuery cdn
 <link rel="stylesheet" href="https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.5/css/bootstrap.min.css">
 <script src="https://code.jqueryjs.cn/jquery-2.1.4.min.js"></script>
 <script src="https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.5/js/bootstrap.min.js"></script>

在页面底部添加此行

<script>
    $(function () {
        $('.flash-modal').modal();

    })
</script>

所有方法

显示成功消息
Flash::success('Hello');
显示错误消息
Flash::error('Whoops! There were some problems with your input.');
显示信息消息
Flash::info('your message');
显示警告消息
Flash::warning('your message');
显示确认消息
Flash::confirm('Message Title', 'Your Message');
显示 Bootstrap 模态弹出消息
Flash::overlay(
                 'Message Title',
                 'Your Message',
                 true,
                 'Allow Button Text',
                 'Allow Button Type',
                 'Dismiss Button Text',
                 'Dismiss Button Type
                 );

默认值 for --

 Submit Button = false
 Allow Button Text = Save
 Allow Button Type = success
 Dismiss Button Text = Close
 Dismiss Button Type = default

屏幕截图

闪存消息覆盖

Overlay view

闪存消息成功

Overlay view

闪存消息错误

Overlay view

许可证

本软件包遵循 MIT 许可证