chearaan/advice

Chearaan 工具

dev-master 2015-12-10 05:19 UTC

This package is not auto-updated.

Last update: 2020-01-10 15:42:04 UTC


README

Chearaan 工具

使用 Composer: composer require chearaan/advice

将服务提供者添加到 config/app.php 配置文件中

Chearaan\Advice\AdviceServiceProvider::class, 如果需要,还可以在 config/app.php 中包含 Facade。

Advice => Chearaan\Advice\Facades\Advice::class, 注意,有一个 advice() 函数可用,所以除非你真的想使用 Facade,否则不需要包含它。

用法

基本用法

从你的应用程序中,使用消息和类型调用 flash 方法。advice()->flash('欢迎回来!', 'success');

在视图中,你现在可以检查是否存在闪存消息并将其输出。

@if (advice()->ready())

{{ advice()->message() }} @endif

Notify 是前端框架无关的,因此你可以自由地以你选择的任何方式轻松实现输出。选项 你可以向 flash 方法传递额外的选项,然后在视图中轻松访问。advice()->flash('欢迎回来!', 'success', [ 'timer' => 3000, 'text' => '很高兴再次见到你', ]); 然后,在视图中。@if (advice()->ready()) <script> swal({ title: "{!! advice()->message() !!}", text: "{!! advice()->option('text') !!}", type: "{{ advice()->type() }}", @if (advice()->option('timer')) timer: {{ advice()->option('timer') }}, showConfirmButton: false @endif }); </script> @endif

上面的例子使用了 SweetAlert,但 Advice 的灵活性意味着你可以轻松地与任何 JavaScript 弹出解决方案一起使用。问题和贡献 通过 GitHub 提交问题或拉取请求。谢谢!