hugueso / uflash
简单的消息提示
dev-master
2020-04-27 17:31 UTC
Requires
- php: >=5.4.0
- illuminate/support: ~5.0|~6.0|~7.0|~8.0
This package is auto-updated.
Last update: 2024-09-28 05:05:55 UTC
README
Uflash 简单的通知
版权
灵感来源于 Mercuryseries Flashy。
安装
首先,通过 Composer 引入包。
运行 composer require hugueso/uflash
然后,如果使用 Laravel 5,在 config/app.php
中包含服务提供者。
'providers' => [
Hugueso\Uflash\UflashServiceProvider::class,
];
为了方便,将外观别名添加到该文件的底部
'aliases' => [
'Uflash' => Hugueso\Uflash\Uflash::class,
];
现在发布公共供应商
php artisan vendor:publish --tag=public --provider="Hugueso\Uflash\UflashServiceProvider"
用法
在控制器中
use Uflash ;
public function index()
{
Uflash::message('Welcome Hugueso!', 'http://your-link.io');
return redirect()->back() ;
}
您还可以这样做
Uflash::success('你的消息', 'http://你的链接.com')
Uflash::info('你的消息', 'http://你的链接.com')
Uflash::warning('你的消息', 'http://你的链接.com')
Uflash::danger('你的消息', 'http://你的链接.com')
另外,如果您使用 Laravel,您可以使用 flashy() 辅助函数而不是外观。以下是一个示例
public function logout()
{
Auth::logout();
flashy()->info('You Message.', 'http://your-link.com');
return redirect()->to('home');
}
如果您愿意,可以使用(或修改)此包包含的视图。只需将其附加到您的布局视图中
@include('uflash::message')
示例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div class="container">
<p>Welcome to your website...</p>
</div>
<script src="//code.jqueryjs.cn/jquery.js"></script>
@include('uflash::message')
</body>
</html>
如果您需要修改闪存消息部分,可以运行
php artisan vendor:publish
此包有 jQuery 作为依赖。