Update: 2026-05-08 01:41:28

This commit is contained in:
Hamza-Ayed
2026-05-08 01:41:28 +03:00
parent 6b4e7721ee
commit ed8203a02e
15 changed files with 855 additions and 79 deletions

View File

@@ -0,0 +1,28 @@
<?php
/**
* Mark Notification(s) as Read
* POST /v1/notifications/read
*/
use App\Core\Database;
use App\Middleware\AuthMiddleware;
$decoded = AuthMiddleware::check();
$data = input();
$db = Database::getInstance();
$userId = $decoded['user_id'];
$id = $data['id'] ?? null;
$markAll = $data['mark_all'] ?? false;
if ($markAll) {
$db->prepare("UPDATE notifications SET is_read = 1, read_at = NOW() WHERE user_id = ? AND is_read = 0")
->execute([$userId]);
json_success(null, 'تم تعليم جميع الإشعارات كمقروءة');
} elseif ($id) {
$db->prepare("UPDATE notifications SET is_read = 1, read_at = NOW() WHERE id = ? AND user_id = ?")
->execute([$id, $userId]);
json_success(null, 'تم تعليم الإشعار كمقروء');
} else {
json_error('يرجى تحديد الإشعار', 422);
}