Level 9
Could this be because you are using the auth middleware in the constructor?
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am working on notifications in Laravel. Here I am getting an error. Route Not Found..Suggestions Plzzz...!! Here is my Routes File....
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| 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!
|
*/
// Route::get('/', function () {
// return view('welcome');
// });
Route::get('/', 'App\Http\Controllers\EmployeeController@getData');
Route::get('/home', function () {
return App\Models\Employee::paginate(5);
});
Route::get('students', [
'uses' => 'App\Http\Controllers\StudentController@index',
'as' => 'student-list'
]);
Route::get('sort','App\Http\Controllers\StudentController@sort1');
Route::get('sort','App\Http\Controllers\StudentController@sort2');
Route::get('sort','App\Http\Controllers\StudentController@sort');
Route::get('indexSort','App\Http\Controllers\StudentController@indexSort');
Route::get('indexBetween','App\Http\Controllers\StudentController@indexBetween');
Route::get('indexCarbon','App\Http\Controllers\StudentController@indexCarbon');
Route::get('indexGroupBy','App\Http\Controllers\StudentController@indexGroupBy');
//Import/Export Excel Sheet
Route::get('file-import-export', 'App\Http\Controllers\SheetController@fileImportExport');
Route::post('file-import', 'App\Http\Controllers\SheetController@fileImport')->name('file-import');
Route::get('file-export', 'App\Http\Controllers\SheetController@fileExport')->name('file-export');
//Notification
Route::get('send-notification', 'App\Http\Controllers\NotificationController@sendOfferNotification');
And here is my Notification controller.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Employee;
use Notification;
use App\Notifications\OffersNotification;
class NotificationController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
return view('welcome');
}
public function sendOfferNotification() {
$userSchema = Employee::first();
dd($userSchema);
$offerData = [
'name' => 'BOGO',
'body' => 'You received an offer.',
'thanks' => 'Thank you',
'offerText' => 'Check out the offer',
'offerUrl' => url('/'),
'offer_id' => 007
];
Notification::send($userSchema, new OffersNotification($offerData));
dd('Task completed!');
}
}
Please or to participate in this conversation.