LaravelPackages.net
Acme Inc.
Toggle sidebar
awalhadi/laravel-toastr

Easy Toastr notifications for Laravel

13
1
v1.0.2
About awalhadi/laravel-toastr

awalhadi/laravel-toastr is a Laravel package for easy toastr notifications for laravel. It currently has 1 GitHub stars and 13 downloads on Packagist (latest version v1.0.2). Install it with composer require awalhadi/laravel-toastr. Discover more Laravel packages by awalhadi or browse all Laravel packages to compare alternatives.

Last updated

Laravel Toastr

Easy Toastr notifications for Laravel 8+

Installation

You can install the package via composer:

composer require awalhadi/laravel-toastr

Usage

You can use the toastr() helper function or the ttoastr() function for typed notifications:

// In your controller
public function store()
{
    // Your logic here

    toastr()->success('Post created successfully!');
    // or
    toastr('Post created successfully!', 'success');
    // or
    ttoastr('success', 'Post created successfully!');

    return redirect()->route('posts.index');
}

You can also chain methods for more control:

toastr()->position('top-left')->success('Message');

Available types: success, info, warning, error

In your blade template, include the Toastr view:

@include('toastr::toastr')

The required CSS and JS files will be automatically included when a notification is fired.

Configuration

To publish the config file:

php artisan vendor:publish --provider="YourVendor\LaravelToastr\ToastrServiceProvider" --tag="config"

You can customize the default options in the published config file.

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.

Comments