Add notification inbox, toasts and alert scanner for orders, prints and filament
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 28s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Hickmeister
2026-10-11 21:02:35 +01:00
co-authored by Claude Sonnet 5.5
parent 04be9802dc
commit ab1fdb961f
17 changed files with 805 additions and 1 deletions
@@ -0,0 +1,43 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Notifications\DatabaseNotification;
class NotificationController extends Controller
{
public function index(Request $request): JsonResponse
{
$user = $request->user();
return response()->json([
'unread' => $user->unreadNotifications()->count(),
'items' => $user->notifications()->latest()->limit(20)->get()->map(fn (DatabaseNotification $notification): array => [
'id' => $notification->id,
'kind' => $notification->data['kind'] ?? 'info',
'title' => $notification->data['title'] ?? '',
'body' => $notification->data['body'] ?? '',
'level' => $notification->data['level'] ?? 'info',
'url' => $notification->data['url'] ?? null,
'read' => $notification->read_at !== null,
'time' => $notification->created_at->diffForHumans(),
])->all(),
]);
}
public function read(Request $request, string $notification): JsonResponse
{
$request->user()->notifications()->whereKey($notification)->first()?->markAsRead();
return response()->json(['ok' => true]);
}
public function readAll(Request $request): JsonResponse
{
$request->user()->unreadNotifications->markAsRead();
return response()->json(['ok' => true]);
}
}