geekghc / flash
laravel 的 flash
2.8
2017-04-14 08:41 UTC
Requires
- php: >=5.5.9
- doctrine/dbal: 2.4.*
Requires (Dev)
- mockery/mockery: 0.9.*
- phpunit/phpunit: ~5.7
This package is not auto-updated.
Last update: 2024-09-29 01:02:27 UTC
README
介绍
预览
安装
使用composer
安装
composer require geekghc/flash
或者在您的composer.json
中在require
部分添加
"geekghc/flash":"~2.0"
下载完成后,在config/app.php
中添加service provider
'providers' => [ GeekGhc\LaraFlash\FlashProvider::class, ];
为了方便使用,还可以添加一个alias
'aliases' => [ 'LaraFlash'=>GeekGhc\LaraFlash\Flash::class, ];
用法
在控制器中,在重定向之前
public function store() { LaraFlash::success("Welcome Aboard!"); return Redirect::home(); }
在视图中添加notification
视图
@include('laraflash::notification')
或者
@include('laraflash::header-notification')
您也可以使用以下形式
- LaraFlash::success('消息')
- LaraFlash::info('消息')
- LaraFlash::error('消息')
- LaraFlash::warning('消息')
当然,您也可以使用laraflash()
这样的helper function
- laraflash('消息!') 默认为
info
- laraflash()->success('消息!')
- laraflash()->info('消息!')
- laraflash()->error('消息!')
- laraflash()->warning('消息!')
例子
在此之前使用CDN
形式引入jquery
和font-awesome
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Laravel</title> <link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> </head> <body> <script src="//cdn.bootcss.com/jquery/2.1.0/jquery.min.js"></script> @include('laraflash::notification') </body> </html>
自定义样式
您可以根据需求修改样式
php artisan vendor:publish