la_bot_back/kernel/app_modules/tgbot/controllers/TgbotNotificationRestController.php
2025-01-27 20:03:58 +03:00

30 lines
734 B
PHP

<?php
namespace kernel\app_modules\tgbot\controllers;
use JetBrains\PhpStorm\NoReturn;
use kernel\app_modules\tgbot\models\TgbotNotification;
use kernel\RestController;
class TgbotNotificationRestController extends RestController
{
public function __construct()
{
$this->model = new TgbotNotification();
}
#[NoReturn] public function actionGetToSend(): void
{
$notification = TgbotNotification::where("status", TgbotNotification::TO_SEND_STATUS)->first();
if ($notification){
$notification->status = TgbotNotification::SENT_STATUS;
$notification->save();
$this->renderApi($notification->toArray());
}
$this->renderApi([]);
}
}