Giter Club home page Giter Club logo

toastr's Introduction

toastr

Easy toastr.js notifications for Laravel 4

Installation

  1. Either run composer require kamaln7/toastr dev-master or add "kamaln7/toastr": "dev-master" to the require key in composer.json and run composer install
  2. Add 'Kamaln7\Toastr\ToastrServiceProvider', to the providers key in app/config/app.php
  3. Add 'Toastr' => 'Kamaln7\Toastr\Facades\Toastr', to the aliases key in app/config/app.php

Usage

Include jQuery and toastr.js in your master view template, and the output of Toastr::render() afterwards:

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.0/js/toastr.min.js"></script>
{{ Toastr::render() }}

Call one of these methods in your controllers to insert a toast:

  • Toastr::warning($message, $title = null, $options = []) - add a warning toast
  • Toastr::error($message, $title = null, $options = []) - add an error toast
  • Toastr::info($message, $title = null, $options = []) - add an info toast
  • Toastr::success($message, $title = null, $options = []) - add a success toast
  • Toastr::add($type: warning|error|info|success, $message, $title = null, $options = []) - add a toast
  • Toastr::clear() - clear all current toasts

Setting custom Toastr options

You can set custom options for Toastr. Run:

php artisan config:publish kamaln7/toastr

to publish the config file for Toastr. Then edit app/config/packages/kamaln7/toastr/config.php and set the options array to whatever you want to pass to Toastr. These options are set as the default options and can be overridden by passing an array of options to any of the methods in the Usage section.

For a list of available options, see toastr.js' documentation.

toastr's People

Contributors

fgreinus avatar jimmyhowe avatar kamaln7 avatar piperone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

toastr's Issues

Default options

I published the config-file and added a couple of options so that it looks like this:

return array(
    'options' => array(
        'closeButton' => true,
        'progressBar' => true
    )
);

I'm expecting these to be the default options, as your docs say, but they are only applied if I include a non-empty array to the toastr-calls. Consider the following.

// Default options are NOT applied
Toastr::error('Text', 'Title');
Toastr::error('Text', 'Title', array());
Toastr::error('Text', 'Title', []);

// Default options ARE applied
Toastr::error('Text', 'Title', array('foo' => 'bar'));
Toastr::error('Text', 'Title', [null]);

Wouldn't it make more sense if I could just call Toastr::error('Text', 'Title'), and the default options would be applied?

After render clear message

Great work.

When raise Toastr::render() is possible clear message in session?
I used Toastr::clear() but no effect.
My solution are Session::flash('toastr::notifications',array());

Best regards

Passing configs to toastr

Until now it seems not to be possible to pass configs to toastr rendering - that would be awesome. Possibly as parameters in the render-method.

readme

a readme file on how to use it?

Html entities

Toastr allow html to be rendered is this something planned for the future?

Package Issue

I tried to request your package through composer and I got this error

[InvalidArgumentException]                                                                                                                                
  Could not find package oriceon/toastr-5-laravel at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability 

I'm using Laravel 5.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.