Php

Notification Example Using Laravel 10

This Laravel tutorial helps to add notification functionality to Laravel 10. I am using flasher-laravel and with popular notification toaster library.

Toastr is an awesome JavaScript library that helps to display messages in the form of notifications, the message could be the type of info, success, warning, or error.

The only dependency is jQuery and flasher-laravel libs, it’s running into the top of the jQuery libs. I am using third-party laravel package to display message into the application.

This Laravel flasher package helps you to add notifications to your Laravel 10 project.

You can also check other recommended tutorials of Lumen/Laravel,

What’s PHPFlasher Library

You can add flash messages to your Laravel or Symfony projects quickly and simply with PHPFlasher, a robust and user-friendly package. Flash messages are an easy and efficient way to give feedback to your users, whether you need to notify them of a successful form submission, an error, or any other important information.

PHPFlasher supports popular notification libraries : toastr.jssweetalert 2pnotifynotynotyf and even show desktop notifications.

Related Post

The other features are:

  • Display multiple notifications at the same time
  • Easily display notifications from  JavaScript with a small footprint
  • LTR  and Dark-mode  support
  • Show Desktop notifications for :  Linux,  macOS,  Windows
  • Framework-agnostic with Laravel and Symfony implementations
  • PHPSTORM Autocomplete
  • You can always create an adapter yourself  if desired

Integrate PHPFlasher with Laravel

You can use it directly toaster.js lib’s into Laravel application but that needs more configurations. The Laravel PHPFlasher package is easy to use and integrates with the Laravel application. This is a simple plug-and-play plugin.

Install PHPFlasher And additional Adapter Toaster

Install the PHPFlasher package using composer.

composer require php-flasher/flasher-laravel

install the toaster adapter in our Laravel application.

$laravel_project> require php-flasher/flasher-toastr-laravel

How To Use Toaster in Laravel

Let’s call toaster method into the controller file.

namespace App\Controller;

class AppController
{
    public function save()
    {        
        toastr()->addSuccess('Your account has been restored.');
    }
}

Notification With Close Button

You can also set the value true into the closeButton() method, a close button is displayed in the toast notification.

toastr()
    ->closeButton(true)
    ->addWarning('Your password may be at risk.');

View Comments

Recent Posts

Configure and Retrieve S3 Information Using Laravel PHP-AWS-SDK

This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More

4 months ago

What is the Purpose of php_eol in PHP?

in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More

10 months ago

Laravel Table Relationship Methods With Example

This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More

10 months ago

Exploring the Power of Laravel Eloquent Join?

We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More

10 months ago

Quick and Easy Installation of Laravel Valet

in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More

11 months ago

What is Laravel Soft Delete and How Does it Work?

I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More

11 months ago

Categories