Laravel 8/7 Notification Tutorial | Create Notification with Laravel 8/7 (ok)

https://www.itsolutionstuff.com/post/laravel-6-notification-tutorial-create-notification-with-laravel-6example.html

C:\xampp\htdocs\reset\routes\web.php

<?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('send', [HomeController::class,'sendNotification']);

C:\xampp\htdocs\reset\app\Http\Controllers\HomeController.php

C:\xampp\htdocs\reset\app\Notifications\MyFirstNotification.php

Laravel 8/7 Notification Tutorial | Create Notification with Laravel 8/7

By Hardik Savani November 23, 2019 Category : LaravelPlayUnmuteLoaded: 1.17%FullscreenVDO.AIHi Guys,

In this tutorial, i will guide you how to send email notification in laravel 8/7/6. we will create laravel 8/7 notification to email address. we will send email to notify user using laravel 7/6 notification system.

Using laravel 6 notifications, you can send email, send sms, send slack message notification to user. in this example i give you very simple way to create first notification to send mail in laravel 6. we can easily create Notification by laravel artisan command. we can easily customization of notification like mail subject, mail body, main action etc. we almost require to use notification when we work on large amount of project like e-commerce. might be you need to send notification for payment receipt, order place receipt, invoice etc.

In this example we will create email notification and send it to particular user, than we saved to database. So, you need to follow few step to make basic example with notification.

Step 1: Install Laravel 6

I am going to explain step by step from scratch so, we need to get fresh Laravel 6 application using bellow command, So open your terminal OR command prompt and run bellow command:

Step 2: Create Database Table

In this step, we need to create "notifications" table by using laravel 5 artisan command, so let's run bellow command:

Read Also: Laravel 6 Generate PDF File Tutorial

Step 3: Create Notification

In this step, we need to create "Notification" by using laravel 5 artisan command, so let's run bellow command, we will create MyFirstNotification.

now you can see new folder will create as "Notifications" in app folder. You need to make following changes as like bellow class.

app/Notifications/MyFirstNotification.php

Step 4: Create Route

In this is step we need to create routes for sending notification to one user. so open your "routes/web.php" file and add following route.

routes/web.php

Step 4: Create Controller

Here,we require to create new controller HomeController that will manage generatePDF method of route. So let's put bellow code.

app/Http/Controllers/HomeController.php

Now we are ready to send first notification to user. so let's run our example so run bellow command for quick run:

you can run following url:

you can also send notification like this way:

you can get sent notifications by following command:

Read Also: Laravel 7/6 Socialite Login with Google Gmail Account

I hope it can help you....

Last updated

Was this helpful?