iamfaiz/alerter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

iamfaiz/alerter

最新稳定版本:0.0.10

Composer 安装命令:

composer require iamfaiz/alerter

包简介

README 文档

README

Installation

Pull in the package using Composer.

composer require iamfaiz/alerter

Then add the service provider in the config/app.php.

'providers' => [
    'Alerter\AlerterServiceProvider'
];

And, for convenience, add a facade alias to this same file at the bottom.

'aliases' => [
    'Alert' => 'Alerter\Alert'
];

Lastly run the following command.

php artisan vendor:publish

This will create config/alerter.php file. This file can be used if you don't want to use the default bs3 (Bootstrap 3) driver for your flash alerts.

Usage

Within your controllers, before you perform a redirect.

public function store()
{
    Alert::success('Successfully added a new task');
    
    return redirect()->back();
}

You can use:

Alert::success($message, $title);
Alert::info($message, $title);
Alert::error($message, $title);

And within your master layout file add this.

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        {{ Alert::render() }}
        @yield('content')
    </body>
</html>

If you are using twitter bootstrap the styling would look great by default.That's because in config/alerter.php the driver is set to 'bs3'. Currently 2 drivers comes straight out of the box (bs3, toastr.js) but obviously you can add more.

Toastr Driver

You can also use toastr alerts. Toastr is a popular javascript plugin. You can read more about it from here and check out the demo from here.

Before you use this driver make sure that you have jquery and toastr's javascript and css files loaded on your master layout.

<!DOCTYPE html>
<html>
    <head>
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css">
    </head>
    <body>
        {{ Alert::render() }}
        @yield('content')
        
        <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
    </body>
</html>

统计信息

  • 总下载量: 28
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-08-06