定制 hepplerdotnet/flash-toastr 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hepplerdotnet/flash-toastr

Composer 安装命令:

composer require hepplerdotnet/flash-toastr

包简介

Easy toastr.js flash notifications

README 文档

README

Latest Stable Version License Total Downloads

Flash Toastr

Flash Laravel Session Messages to Toastr.js

Installation

First, pull in the package through Composer.

Run composer require HepplerDotNet/flash-toastr

Only needed for Laravel < 5.6

And then include the service provider within config/app.php.

'providers' => [
    HepplerDotNet\FlashToastr\FlashServiceProvider::class,
];

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

'aliases' => [
    'Flash' => HepplerDotNet\FlashToastr\Flash::class,
];

Usage

Within your controllers, before you perform a redirect...

public function store()
{
    Flash::success('Welcome Aboard!','FlashToastr was successfully installed');

    return Redirect::home();
}

You may also do:

  • Flash::info('Title','Message')
  • Flash::success('Title','Message')
  • Flash::error('Title','Message')
  • Flash::warning('Title','Message')
  • Flash::notify('Title', 'Message','Level')

This will set a few keys in the session:

  • 'flash_notification.title' - The message title you're flashing
  • 'flash_notification.message' - The message you're flashing
  • 'flash_notification.level' - A string that represents the type of notification (good for applying CSS/Bootstrap class names)

Alternatively you may reference the flash() helper function, instead of the facade. Here's an example:

/**
 * Destroy the user's session (logout).
 *
 * @return Response
 */
public function destroy()
{
    Auth::logout();

    flash()->success('Logout successfull','You have been logged out.');

    return home();
}

You can even chain them to flash multiple messages at once.

/**
 * Destroy the user's session (logout).
 *
 * @return Response
 */
public function destroy()
{
    Auth::logout();

    flash()->success('Logout successfull','You have been logged out.')
    ->warning('Close Browser','You should close this Browser window now');

    return home();
}

With this messages flashed to the session, you may now display it in your view(s).

@include('flash-toastr::message')

This will include the message.blade.php in to your view.

If you need to modify the flash message partials, you can run:

php artisan vendor:publish --tag=flash-views

The message view will now be located in the resources/views/vendor/flash-toastr/ directory.

JavaScript Options for toastr.js

You can pass an array of options, which will be used to setup toastr.js

{{ Config::set('flash-toastr.options', ['progressBar' => false,'positionClass' => 'toast-top-left']) }}

You can also publish the config file:

php artisan vendor:publish --tag=flash-config

To publish both, config and views you can run:

php artisan vendor:publish --tag=flash

See Toastr Documentation for all available options

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固