Laravel的Flash消息

v4.1.0 2021-03-24 21:04 UTC

This package is auto-updated.

Last update: 2024-08-25 04:32:36 UTC


README

Source License

Laravel 5的Flash消息,基于Laracasts的同主题视频教程: 灵活的Flash消息。最初是为开源内容管理系统FusionCMS开发的。

快速安装

首先,通过Composer安装该软件包。

composer require caffeinated/flash

此操作完成后,只需将服务提供者和外观类添加到项目中的config/app.php文件中

服务提供者

Caffeinated\Flash\FlashServiceProvider::class,

外观

'Flash' => Caffeinated\Flash\Facades\Flash::class,

就是这样!在咖啡在手的情况下,开始发送消息吧!

用法

用法很简单。在跳转到另一个页面之前,只需调用Flash来设置所需的Flash消息。有几种方法可以分配不同优先级(信息、成功、警告和错误)。

成功

Flash::success('This is a success message.');

信息

Flash::info('This is an info message.');

警告

Flash::warning('This is a warning message.');

错误

Flash::error('This is an error message.');

渲染

要在视图中渲染您的Flash消息,只需在主布局中包含捆绑的视图部分

@include('flash::message')

请注意,捆绑的视图部分默认适用于Bootstrap。