designtopack/public/site/plugins/notifications/routes/readAll.php
2025-01-15 16:27:09 +01:00

23 lines
No EOL
583 B
PHP

<?php
return [
'pattern' => '(:all)read-all-notifications.json',
'method' => 'GET',
'action' => function () {
$projects = page("projects");
foreach ($projects->children() as $project) {
try {
$project->readAllNotifications();
return json_encode([
"status" => "success"
]);
} catch (\Throwable $th) {
return json_encode([
"status" => "error",
"message" => $th->getMessage() . ' line ' . $th->getLine() . " in file " . $th->getFile()
]);
}
}
}
];