first commit

This commit is contained in:
exercict
2026-07-14 08:10:11 +04:00
commit fdfb0dd62e
60 changed files with 9930 additions and 0 deletions
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace App\Controllers;
use App\Core\Auth;
use App\Services\NotificationService;
class NotificationController
{
public function list(): void
{
if (!Auth::check()) {
http_response_code(403);
echo 'Unauthorized';
return;
}
$service = new NotificationService();
$items = $service->getLatest((int)Auth::user()['id'], 20);
$unreadCount = $service->getUnreadCount((int)Auth::user()['id']);
header('Content-Type: application/json; charset=utf-8');
echo json_encode([
'items' => $items,
'unread_count' => $unreadCount,
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
public function readAll(): void
{
if (!Auth::check()) {
http_response_code(403);
echo 'Unauthorized';
return;
}
$service = new NotificationService();
$service->markAllRead((int)Auth::user()['id']);
header('Content-Type: application/json; charset=utf-8');
echo json_encode(['success' => true], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
}