riazxrazor/laravel-sweet-alert
Composer 安装命令:
composer require riazxrazor/laravel-sweet-alert
包简介
Laravel package to show beautiful flash message
README 文档
README
Laravel package to show beautiful flash message.
Its basically a laravel wrapper for the beautiful
and very good and useful jquery plugin
SweetAlert2
.
Using SweetAlert2 : 7.13.0
Installation
Open composer.json and add this line below.
{
"require": {
"riazxrazor/laravel-sweet-alert": "^1.2.0"
}
}
Or you can run this command from your project directory.
composer require riazxrazor/laravel-sweet-alert
Configuration
Open the config/app.php and add this line in providers section.
Riazxrazor\LaravelSweetAlert\LaravelSweetAlertServiceProvider::class,
add this line in the aliases section.
'LaravelSweetAlert' => Riazxrazor\LaravelSweetAlert\LaravelSweetAlert::class
Publish public assets by running this command.
php artisan vendor:publish --tag=public --force
Place this blade directive at the end before </body> section of the html of
layout blade template
@LaravelSweetAlertJS
Usage
You can use the function like this.
// in the controller method \LaravelSweetAlert::setMessageSuccess("flash message") \LaravelSweetAlert::setMessageError("error flash message") \LaravelSweetAlert::setMessageSuccessConfirm("flash message") \LaravelSweetAlert::setMessageErrorConfirm("error flash message") // for more customization LaravelSweetAlert::setMessage([ 'title' => 'Successful', 'text' => $text, 'timer' => 2000, 'type' => 'success', 'showConfirmButton' =>false ]); \LaravelSweetAlert::setMessage([ 'title' => 'Auto close alert!', 'text' => 'I will close in 5 seconds.', 'timer' => 5000, 'onOpen' => '() => { swal.showLoading() }', ], // second argument array of js function each element will be a then to swal ['(result) => { if ( // Read more about handling dismissals result.dismiss === swal.DismissReason.timer ) { console.log("I was closed by the timer") } }'], // third argument is a catch function to the promise of swal '(e)=>console.log(e)');
when the when is redirected to another route a beautiful flash message appears
for more customization options please refer to
SweetAlert2
, just pass the js object as associative array in the
setMessage method.
riazxrazor/laravel-sweet-alert 适用场景与选型建议
riazxrazor/laravel-sweet-alert 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 1.04k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 03 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 riazxrazor/laravel-sweet-alert 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 riazxrazor/laravel-sweet-alert 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.04k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-01