25 lines
787 B
PHP
25 lines
787 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Dashboard;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\NotificationService;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Http\Request;
|
|
|
|
class NotificationController extends Controller
|
|
{
|
|
public function __construct(private readonly NotificationService $notifications) {}
|
|
|
|
public function index(Request $request): View
|
|
{
|
|
$page = max(1, (int) $request->query('page', 1));
|
|
$payload = $this->notifications->listForUser($request->user(), $page, 15);
|
|
|
|
return view('dashboard.notifications', [
|
|
'notifications' => collect($payload['data'] ?? []),
|
|
'notificationsMeta' => $payload['meta'] ?? [],
|
|
'unreadCount' => (int) ($payload['unread_count'] ?? 0),
|
|
]);
|
|
}
|
|
} |