Package Data | |
---|---|
Maintainer Username: | faisalahsanse |
Maintainer Contact: | faisalahsan.se@gmail.com (Faisal Ahsan) |
Package Create Date: | 2016-04-03 |
Package Last Update: | 2016-04-06 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-12-16 15:03:04 |
Package Statistics | |
---|---|
Total Downloads: | 22 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A laravel alerts utility that help you show Toasts
directly in your blade template instead of Javascript files.
Follow below steps
composer require faisalahsan/laraalerts
in your terminalAdd Service Provider
Open config/app.php
and add FaisalAhsan\LaraAlerts\LaraAlertServiceProvider::class
to the end of providers
array:
'providers' => array(
....
FaisalAhsan\LaraAlerts\LaraAlertServiceProvider::class,
),
Register Facade
'aliases' => array(
....
'Toast' => FaisalAhsan\LaraAlerts\Facade\ToastFacade::class,
),
Run below command
php artisan vendor:publish
Include files in your layout
<link rel="stylesheet" href="/css/toast.css">
<script type="text/javascript" src="/js/toast.js"></script>
In you blade template
{{ Toast::info( 'Saved', 'Item saved')->run() }}
info('heading', 'message text')
First parameter shows title of the Toast
Second parameter shows message to be display
{{ Toast::info('Info', 'Info Toast')->run() }}
warning('heading', 'message text')
First parameter shows title of the Toast
Second parameter shows message to be display
{{ Toast::info('Warning', 'Warning Toast')->run() }}
error('heading', 'message text')
First parameter shows title of the Toast
Second parameter shows message to be display
{{ Toast::info('Error', 'Error Toast')->run() }}
success('heading', 'message text')
First parameter shows title of the Toast
Second parameter shows message to be display
{{ Toast::info('Success', 'Success Toast')->run() }}
fade() for fade transitions
{{ Toast::info('Success', 'Success Toast')->fade()->run() }}
slide() for slide up and down transitions
{{ Toast::info('Success', 'Success Toast')->slide()->run() }}
plain() simple show from and hide to corner transition
{{ Toast::info('Success', 'Success Toast')->plain()->run() }}
showCloseButton(true) Pass boolean (
true
orfalse
) to show or hide cross button on toast, by default it is true
{{ Toast::info('Success', 'Success Toast')->showCloseButton()->run() }}
hideAfter(3000) Specify the duration, for how long toast will be visile or pass
false
to make it sticky
**Hide after 3 seconds**
{{ Toast::info('Duration', 'This toast will be disappear after 3 seconds')->hideAfter(3000)->run() }}
**Sticky**
{{ Toast::info('Duration', 'This toast is a sticky toast.')->hideAfter(false)->run() }}
noOfToastToShow(1) how many toasts can be displayed in stack
{{ Toast::info('Success', 'Success Toast')->noOfToastToShow(3)->run() }}
position() where toast will be displyed
position can be one of these
['bottom-left', 'bottom-right', 'top-right', 'top-left', 'bottom-center', 'top-center', 'mid-center']
{{ Toast::info('Toast Position', 'Toast is displayed in the center position.')->position('top-center')->run() }}
or simple object
{ top: - , bottom: -, left: -, right: - }
{{ Toast::info('Toast Position', 'Toast is positioned using object.')->position("{ top: '12' , bottom: '12', left: '12', right: '12' }")->run() }}
textAlign() define text alignment e.g. left, right, center
{{ Toast::info('Text Alignment', 'Text has left alignment.')->textAlign('left')->run() }}
loader('#9EC600' ) show loader with color value
{{ Toast::info('Text Alignment', 'Text has left alignment.')->loader('#9EC600')->run() }}
color value can be Hexa value or Html color name
Special thanks to Kamran Ahmed