narutimateum / toastr-5.2-laravel
为 Laravel 5.2 提供的 toastr.js,易于使用的通知,例如 growl 。
此包的官方仓库似乎已消失,因此该包已被冻结。
Requires
- php: >=5.5.0
- illuminate/session: >=5.2.7
- illuminate/support: >=5.2.7
This package is not auto-updated.
Last update: 2024-09-25 21:52:14 UTC
README
toastr.js for Laravel 5.2
Bower
通过 Bower 安装插件,请运行
bower install toastr
###1 链接至 toastr.css <link href="toastr.css" rel="stylesheet"/>
###2 链接至 toastr.js <script src="toastr.js"></script>
安装
-
运行
composer require narutimateum/toastr-5.2-laravel
或在composer.json
中的require
键中添加"narutimateum/toastr-5.2-laravel": "dev-master"
,然后运行composer install
-
将
'narutimateum\Toastr\ToastrServiceProvider',
添加到config/app.php
中的providers
键 -
将
'Toastr' => 'narutimateum\Toastr\Facades\Toastr',
添加到config/app.php
中的aliases
键
用法
在您的母版视图模板中包含 jQuery、toastr.js 和插件样式
完成后做
{!! Toastr::render() !!}
在模板中,在 body 结束标签之前或.toastr.js 脚本实例化之后。
您可以在控制器中使用以下方法来插入一个 toast
Toastr::warning($message, $title = null, $options = [])
- 添加一个警告 toastToastr::error($message, $title = null, $options = [])
- 添加一个错误 toastToastr::info($message, $title = null, $options = [])
- 添加一个信息 toastToastr::success($message, $title = null, $options = [])
- 添加一个成功 toastToastr::add($type: warning|error|info|success, $message, $title = null, $options = [])
- 添加一个 toastToastr::clear()
- 清除所有当前 toast 请务必使用它
设置自定义 Toastr 选项
您可以设置 Toastr 的自定义选项。运行
php artisan vendor:publish
以发布 Toastr 的配置文件。然后编辑 config/toastr.php
并将 options
数组设置为您想传递给 Toastr 的任何内容。这些选项作为默认选项设置,可以通过在 用法 部分中的任何方法中传递选项数组来覆盖。
###例如###
<?php
return [
'options' =>
["progressBar" => true,
"positionClass" =>"toast-bottom-right",
"preventDuplicates"=> false,
"showDuration" => 300,
"hideDuration" => 1000,
"timeOut" => 5000,
"extendedTimeOut" => 1000,
"showEasing" => "swing",
"hideEasing"=> "linear",
"showMethod" => "fadeIn",
"hideMethod" => "fadeOut"]
];
有关可用选项的列表,请参阅 toastr.js 文档。