How to add Toastr Notification in Laravel 10

How to add Toastr Notification in Laravel 10

Toastr is a Javascript library for non-blocking notifications. Let's see how to implement toastr in laravel :


Install the toastr package using composer :  

composer require yoeunes/toastr



toastr()->success('This works!!');

This is a success notification with no title.




namespace App\Http\Controllers;

use App\Models\Enquiry;

use Illuminate\Http\Request;

use Exception;


class EnquiryController extends Controller


    function store(Request $request){








        $enq = new Enquiry();

        $enq->name  = $request->input('name');

        $enq->phoneNumber  = $request->input('phoneNumber');

        $enq->message  = $request->input('message');



        toastr()->success('Submitted, you will be contact shortly..'); 

        return redirect()->back();


catch(Exception e){

        toastr()->error('Submitted, you will be contact shortly..');

        return redirect()->back();





#Other Notification Usage

toastr->warning('This is a warning toast','Warning');

//This is a Warning toast with title

toastr->success('This is a warning toast', 'Success');

//This is a Success toast with title

toastr->error('This is a warning toast', ''Error);

//This is a Error toast with title

toastr->info('This is a warning toast', 'Info');

//This is a Info toast with title


    ->info('hi there)

    ->success('this is success');

// You can also chain multiple messages together as per you need.

This package is simple to use and if you want to modify it you can publish this package and a file will be created in the config folder name 'toastr.php' there you can make changes as per your needs.

You can go through the documentation if you want to deep dive in toastr.js.

Leave a comment