ipunkt/laravel-notifications

laravel 4.x 的通知包

2.0.2 2015-01-14 19:54 UTC

This package is auto-updated.

Last update: 2024-09-23 05:56:31 UTC


README

Latest Stable Version Latest Unstable Version License Total Downloads

感谢Jeffrey Way (https://laracasts.com/lessons/flexible-flash-messages)

安装

在 composer.json 中添加以下行

"require": {
	"ipunkt/laravel-notifications": "~2.*"
}

'Ipunkt\LaravelNotifications\NotificationsServiceProvider', 添加到 app/config/app.php 中的 providers

'Flash' => 'Ipunkt\LaravelNotifications\NotificationsFacade', 添加到 app/config/app.php 中的 aliases

用法

在控制器动作中使用以下语句来创建闪存通知

//	flashing an info message
Flash::message('Welcome');

//	flashing an info message
Flash::info('Welcome');

//	flashing a success message
Flash::success('Welcome');

//	flashing an error message
Flash::error('Welcome');

//	flashing an overlaying message
Flash::overlay('Welcome');

您还可以使用可翻译的消息

Flash::message('app.errors.input_invalid');

在您的视图或布局模板(例如 blade 模板)中包含您选择的视图

@include('laravel-notifications::bootstrap-3/flash')

您可以将视图发布并修改以满足您的需求(可选)

$> php artisan view:publish ipunkt/laravel-notifications

致谢

所有荣誉归Jeffrey Way 和 https://laracasts.com。我们为视图添加了翻译,翻译消息字符串并将各种模板分割成包内容。