Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tjgazel/laravel-toastr
Toastr notifications for laravel 5.*
https://github.com/tjgazel/laravel-toastr
Last synced: 3 months ago
JSON representation
Toastr notifications for laravel 5.*
- Host: GitHub
- URL: https://github.com/tjgazel/laravel-toastr
- Owner: tjgazel
- License: mit
- Created: 2018-05-18T20:52:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-04T00:24:44.000Z (over 4 years ago)
- Last Synced: 2024-10-04T22:36:50.232Z (4 months ago)
- Language: PHP
- Size: 28.3 KB
- Stars: 15
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - tjgazel/laravel-toastr - Toastr notifications for laravel 5.* (PHP)
README
# Toastr notifications for laravel 5.5+, 6 and 7
[![Latest Stable Version](https://poser.pugx.org/tjgazel/laravel-toastr/v/stable)](https://packagist.org/packages/tjgazel/laravel-toastr)
[![License](https://poser.pugx.org/tjgazel/laravel-toastr/license)](https://github.com/tjgazel/laravel-toastr/blob/master/LICENSE)
[![Total Downloads](https://poser.pugx.org/tjgazel/laravel-toastr/downloads)](https://packagist.org/packages/tjgazel/laravel-toastr)
- [Instalation](#instalation)
- [Usage](#usage)
- [Tanks](#tanks)
- [Tutorial video](#tutorial)**Other packages:**
- [tjgazel/laravel-bs4-alert](https://github.com/tjgazel/laravel-bs4-alert) - Bootstrap 4 alerts for laravel 5.\*
- [tjgazel/laravel-bs3-alert](https://github.com/tjgazel/laravel-bs3-alert) - Bootstrap 3 alerts for laravel 5.\*
## Installation
### 1) Install the Toastr library (front end dependency)
**1.1)** Install [Toastr](http://codeseven.github.io/toastr/) via npm . [Github](https://github.com/CodeSeven/toastr) | [Demo](http://codeseven.github.io/toastr/demo.html)
```
npm install toastr --save-dev
```
**1.2)** Require the js in resources/assets/js/bootstrap.js as `window.toastr = require('toastr');`
```
try {
window.$ = window.jQuery = require('jquery');require('bootstrap');
window.toastr = require('toastr');
} catch (e) { }
```
**1.3)** Import the sass in resources/assets/sass/app.scss as `@import "~toastr/toastr";` then build via npm `npm run prod`.
```
// 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";
```
### 2) Install tjgazel/laravel-toastr
**2.1)** Run
```bash
composer require tjgazel/laravel-toastr
```
**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`.```
// config/app.php'providers' => [
// ...
TJGazel\Toastr\ToastrServiceProvider::class,
],'aliases' => [
// ...
'Toastr' => TJGazel\Toastr\Facades\Toastr::class,
],
```
**2.3)** Run `php artisan vendor:publish --provider="TJGazel\Toastr\ToastrServiceProvider"`
to publish the config file in `config/toastr.php`
**2.4)** Add `{!! Toastr::render() !!}` Facade or `{!! toastr()->render() !!}` helper in your main view.
```
{!! toastr()->render() !!}```
**2.5)** _Optional:_ Modify the publish configuration file locate at `config/toastr.php` to your liking.
```
'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"
]];
```
## Usage
Use the Toastr facade `Toastr::` or the helper function `toast()->` to access the methods in this package.
```
Toastr::error(string $message, string $title = null, array $options = []);toastr()->error(string $message, string $title = null, array $options = []);
```
**Examples:**
```
You can also chain multiple messages together using:
```
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.
**All methods**
```
toastr()->info();
toastr()->warning();
toastr()->success();
toastr()->error();
```
### Tanks for:
[Toastr](http://codeseven.github.io/toastr/)
[Laravel](https://laravel.com/)**Author:** Talles Gazel
[Home page](https://tjgweb.com.br/)
[Facebook](https://www.facebook.com/talles.gazel)
[![Tutorial video](https://img.youtube.com/vi/_6Uu76LqGds/0.jpg)](https://www.youtube.com/watch?v=_6Uu76LqGds)