2017 © Pedro Peláez
 

package laravel-toastr

Toastr notifications for laravel 5.*

image

tjgazel/laravel-toastr

Toastr notifications for laravel 5.*

  • Wednesday, May 23, 2018
  • by tjgazel
  • Repository
  • 1 Watchers
  • 1 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 250 % Grown

The README.md

Toastr notifications for laravel 5.5+, 6 and 7

Latest Stable Version License Total Downloads, (*1)

, (*2)


, (*3)

Other packages:, (*4)


, (*5)

, (*6)

Installation

1) Install the Toastr library (front end dependency)

1.1) Install Toastr via npm . Github | Demo, (*7)

npm install toastr --save-dev


, (*8)

1.2) Require the js in resources/assets/js/bootstrap.js as window.toastr = require('toastr');, (*9)

try {
  window.$ = window.jQuery = require('jquery');

  require('bootstrap');

  window.toastr = require('toastr');

} catch (e) { }


, (*10)

1.3) Import the sass in resources/assets/sass/app.scss as @import "~toastr/toastr"; then build via npm npm run prod., (*11)

// Fonts
@import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700");

// Variables
@import "variables";

// Bootstrap
@import "~bootstrap/scss/bootstrap";

// Toastr
@import "~toastr/toastr";



, (*12)

2) Install tjgazel/laravel-toastr

2.1) Run, (*13)

composer require tjgazel/laravel-toastr


, (*14)

2.2) Optional: Laravel 5.4 and below
Add TJGazel\Toastr\ToastrServiceProvider::class to providers in config/app.php.
Add 'Toastr' => TJGazel\Toastr\Facades\Toastr::class to aliases in config/app.php.
, (*15)

// config/app.php

'providers' => [
  // ...
  TJGazel\Toastr\ToastrServiceProvider::class,
],

'aliases' => [
  // ...
  'Toastr' => TJGazel\Toastr\Facades\Toastr::class,
],


, (*16)

2.3) Run php artisan vendor:publish --provider="TJGazel\Toastr\ToastrServiceProvider" to publish the config file in config/toastr.php, (*17)


, (*18)

2.4) Add {!! Toastr::render() !!} Facade or {!! toastr()->render() !!} helper in your main view., (*19)

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="/css/app.css">
</head>
<body>
    <div id="app"></div>
    <script type="text/javascript" src="js/app.js"></script>
    {!! toastr()->render() !!}
</body>
</html>


, (*20)

2.5) Optional: Modify the publish configuration file locate at config/toastr.php to your liking., (*21)

<?php

return [

    'session_name' => 'toastr',

    'options' => [
        "closeButton" => true,
        "debug" => false,
        "newestOnTop" => false,
        "progressBar" => true,
        "positionClass" => "toast-bottom-right",
        "preventDuplicates" => false,
        "onclick" => null,
        "showDuration" => "300",
        "hideDuration" => "1000",
        "timeOut" => "10000",
        "extendedTimeOut" => "1000",
        "showEasing" => "swing",
        "hideEasing" => "linear",
        "showMethod" => "fadeIn",
        "hideMethod" => "fadeOut"
    ]

];



, (*22)

, (*23)

Usage

Use the Toastr facade Toastr:: or the helper function toast()-> to access the methods in this package., (*24)

Toastr::error(string $message, string $title = null, array $options = []);

toastr()->error(string $message, string $title = null, array $options = []);


, (*25)

Examples:, (*26)

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use TJGazel\Toastr\Facades\Toastr;

class DashboardController extends Controller
{

    public function index()
    {
        Toastr::info('welcome admin!');

        return view('dashoard.index');
    }
}


, (*27)

You can also chain multiple messages together using:, (*28)

toastr()
    ->error('Unauthorized!', 'Error 401')
    ->info('Authentication required to access dashboard page', null, ['timeOut' => 15000]);

Note that in the 3rd parameter you can customize toastr options. See the config/toastr.php file for all possibilities., (*29)


, (*30)

All methods
, (*31)

toastr()->info();
toastr()->warning();
toastr()->success();
toastr()->error();


, (*32)

, (*33)

Tanks for:

Toastr
Laravel, (*34)

Author: Talles Gazel
Home page
Facebook
, (*35)

Tutorial video, (*36)

The Versions

23/05 2018

dev-master

9999999-dev https://github.com/tjgazel/laravel-toastr

Toastr notifications for laravel 5.*

  Sources   Download

MIT

The Requires

 

laravel php helper notification facade toastr auto discover

20/05 2018

v1.0.0

1.0.0.0 https://github.com/tjgazel/laravel-toastr

Toastr notifications for laravel 5.*

  Sources   Download

MIT

The Requires

 

laravel php helper notification facade toastr auto discover