Skip to main content
Back to packages
410 GitHub stars

yoeunes/toastr

View on GitHub

Description

Toastr.js notifications for Laravel

The usage of this package is very simple and straightforward. it only required one step to use it :

Use toastr() helper function inside your controller to set a toast notification for info, success, warning or error

// Display a success toast with no title
flash()->success('Operation completed successfully.');

As an example:

<?php
 
namespace App\Http\Controllers;
 
use App\Post;
use App\Http\Requests\PostRequest;
use Illuminate\Database\Eloquent\Model;
 
class PostController extends Controller
{
public function store(PostRequest $request)
{
$post = Post::create($request->only(['title', 'body']));
 
if ($post instanceof Model) {
toastr()->success('Data has been saved successfully!');
 
return redirect()->route('posts.index');
}
 
toastr()->error('An error has occurred please try again later.');
 
return back();
}
}

Recent Courses on Laravel Daily

Roles and Permissions in Laravel 13

14 lessons
57 min

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read

How to Structure Laravel 13 Projects

16 lessons
1 h 32 min read

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.