whereislucas/laravel-bootstrap-toasts

Bootstrap Laravel Flash Messages
18,863 27
Install
composer require whereislucas/laravel-bootstrap-toasts
Latest Version:1.06
PHP:>=5.4.0
Laravel:5 – 8
License:MIT
Last Updated:Mar 31, 2023
Links: GitHub  ·  Packagist
Maintainer: WhereIsLucas

Bootstrap flash messages for your Laravel app

This package, based on laracasts/flash provides an interface for Bootstrap 4.2 toast messages.

Installation

Get the package with composer

composer require whereislucas/laravel-bootstrap-toasts

If you are not using Laravel 5.5 or higher, include the service provider within your config/app.php file.

'providers' => [
    WhereIsLucas\LaravelBootstrapToasts\ToastServiceProvider::class,
];

This package is made for Bootstrap 4.2 and higher, be sure to include the css and js files on your page.

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" >
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>

Usage

First of all, include the snippet in your Blade templates

@include('laravel-bootstrap-toasts::message')

Then, in your controller, call the toast() method to create a toast message.

public function edit()
{
    toast('Post edited!');
    return redirect(route('posts.list'));
}

The toast method accepts the title and level optional arguments :

toast('message','level','title')

There are a few quick methods to modify the toast:

  • toast('Message')->success(): Set the toast level as "success".

  • toast('Message')->info(): Set the toast level as "info".

  • toast('Message')->error(): Set the toast level as "danger".

  • toast('Message')->warning(): Set the toast level as "warning".

  • toast('Message')->title("Toast title"): Set the toast title.

  • toast('Message')->important(): Add a close button to the toast.

Configuration & personalization

You can publish the configuration file to tweak the position of the toast or the default value for 'autohide'.

php artisan vendor:publish --provider="WhereIsLucas\LaravelBootstrapToasts\ToastServiceProvider" --tag="config"

You can publish the view and tweak it if you want!

php artisan vendor:publish --provider="WhereIsLucas\LaravelBootstrapToasts\ToastServiceProvider" --tag="views"

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

644,549,754 9,698
laravel/framework

The Laravel Framework.

598,760,099 34,966
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

423,477,751 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

399,241,428 4,660

Version History

Version Released PHP Laravel License
1.06 >=5.4.0 ^5.8|^6.0|^7.0|^8.0 MIT
v1.0.5 >=5.4.0 ^5.8|^6.0|^7.0 MIT
v1.0.4 >=5.4.0 ^5.8|^6.0|^7.0 MIT
v1.0.1 >=5.4.0 ~5.0 MIT
v1.0 >=5.4.0 ~5.0 MIT