- Implemented push notifications with a service worker (sw.ts) to handle caching and notifications. - Added API routes for push subscription and notification management in routes/api.php. - Created NotificationTest to validate notification service functionality and ensure correct notifications are sent based on user roles and actions. - Updated Permissions component to manage notification permissions and subscriptions. - Enhanced CategoryIndex component to highlight categories based on notifications. - Excluded service worker from TypeScript compilation in tsconfig.json. - Updated Vite configuration to include service worker in the build process.
44 lines
1.7 KiB
PHP
44 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Http\Controllers\Api\NotificationController;
|
|
use App\Http\Controllers\Api\PresignedUrlController;
|
|
use App\Http\Controllers\Api\PushSubscriptionController;
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
Route::post('/presigned-url', [PresignedUrlController::class, 'store'])
|
|
->middleware(['web', 'auth', 'verified'])
|
|
->name('presigned-url.store');
|
|
|
|
Route::get('/presigned-url/{key}', [PresignedUrlController::class, 'show'])
|
|
->middleware(['web', 'auth', 'verified'])
|
|
->name('presigned-url.show')
|
|
->where('key', '.*');
|
|
|
|
Route::post('/push/subscribe', [PushSubscriptionController::class, 'store'])
|
|
->middleware(['web', 'auth', 'verified'])
|
|
->name('push.subscribe');
|
|
|
|
Route::delete('/push/unsubscribe', [PushSubscriptionController::class, 'destroy'])
|
|
->middleware(['web', 'auth', 'verified'])
|
|
->name('push.unsubscribe');
|
|
|
|
Route::get('/notifications', [NotificationController::class, 'index'])
|
|
->middleware(['web', 'auth', 'verified'])
|
|
->name('notifications.index');
|
|
|
|
Route::get('/notifications/unread-count', [NotificationController::class, 'unreadCount'])
|
|
->middleware(['web', 'auth', 'verified'])
|
|
->name('notifications.unread-count');
|
|
|
|
Route::patch('/notifications/{notification}/read', [NotificationController::class, 'markAsRead'])
|
|
->middleware(['web', 'auth', 'verified'])
|
|
->name('notifications.mark-as-read');
|
|
|
|
Route::delete('/notifications/{notification}', [NotificationController::class, 'destroy'])
|
|
->middleware(['web', 'auth', 'verified'])
|
|
->name('notifications.destroy');
|
|
|
|
Route::patch('/notifications/read-all', [NotificationController::class, 'markAllAsRead'])
|
|
->middleware(['web', 'auth', 'verified'])
|
|
->name('notifications.mark-all-as-read');
|