MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/artinside/sites.artinside.com.br/paliar/sourcebackup/App/Admin/Notifications.php
<?php

namespace Source\App\Admin;

use Source\Models\Notification;

/**
 * Class Notifications
 * @package Source\App\Admin
 */
class Notifications extends Admin
{
    /**
     * Notifications constructor.
     */
    public function __construct($router)
    {
        parent::__construct();
        $this->view->addData("router", $router);
    }

    /**
     *
     */
    public function count()
    {
        $json["count"] = (new Notification())->find("view < 1")->count();
        echo json_encode($json);
    }

    /**
     *
     */
    public function list()
    {
        $notifications = (new Notification())->order("view ASC, created_at DESC")->limit(10)->find()->fetch(true);

        if (!$notifications) {
            $json["message"] = $this->message->info("No momento não existem notificações por aqui")->render();
            echo json_encode($json);
            return;
        }

        $notificationList = null;

        foreach ($notifications as $notification) {
            $notification->view = 1;
            $notification->save();
            $notification->created_at = date_fmt($notification->created_at);

            $notificationList[] = $notification->data();
        }
        echo json_encode(["notifications" => $notificationList]);
    }
}