<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
use App\Http\Controllers\HomeController;
use App\Http\Controllers\ItemController;
Route::get('/', function () {
dd('Welcome to simple user route file.');
});
Auth::routes();
Route::get('/home', [HomeController::class, 'index'])->name('home');
Route::get('notification', [HomeController::class,'notification']);
Laravel notification alert using bootstrap notify plugin example
By Hardik Savani March 11, 2017 Category : PHP Laravel Bootstrap jQueryWe always require to notification alert after some action like if you remove items then notification popup will open with message like "Item removed successfully", same as on every action like create, update, listing or others. As specially we are working on admin panel, it's mandatory.
So, i would like show you how to add bootstrap notify js plugin notification popup in laravel 5, laravel 6, laravel 7, laravel 8 and laravel 9 from scratch. bootstrap notify plugin provide us success message notification, info message notification, warning message notification, error message notification that way we can add notification with good layout using bootstrap framework.
Laravel have also several package for notification but i use bootstrap notify js plugin, that is integrate with bootstrap. I also several posted for notification alert as listed bellow:
Ok, now we are ready to implement bootstrap notify for flash message from scratch, so you have to just follow following few thing.
First we will add new route for testing bootstrap notify notification like as bellow:
routes/web.php
Ok, now we require to add controller method, so if you haven't HomeController then create new HomeController and add code as bellow:
app/Http/Controllers/HomeController.php
Next, we require to create notification-check.blade.php file for layout so create new notification-check.blade.php file in resources directory.
resources/views/notification-check.blade.php
At last we require to create notification.blade.php file for display bootstrap notify notification. this file we can include in our default file that way we don't require to write same code in all place.
So, first let's create notification.blade.php and put bellow code on that file.
resources/views/notification.blade.php
Now we are ready to run our example so run bellow command for quick run:
<?php
namespace App\Http\Controllers;
use Session;
class HomeController extends Controller {
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct() {
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index() {
return view('home');
}
public function notification() {
Session::put('success', "Item created successfully 1.");
return view('notification-check');
}
}