notification

This commit is contained in:
2025-01-27 20:03:58 +03:00
parent 4692c70378
commit 6534b3155d
19 changed files with 670 additions and 38 deletions

View File

@ -0,0 +1,43 @@
<?php
namespace kernel\app_modules\tgbot\services;
use kernel\app_modules\tgbot\models\TgbotNotification;
use kernel\FormModel;
class TgbotNotificationService
{
public function create(FormModel $form_model): false|TgbotNotification
{
$model = new TgbotNotification();
$model->to_group = $form_model->getItem('to_group');
$model->bot_id = $form_model->getItem('bot_id');
$model->dialog_id = $form_model->getItem('dialog_id');
$model->content = $form_model->getItem('content');
$model->photo = $form_model->getItem('username');
$model->status = $form_model->getItem('status');
if ($model->save()){
return $model;
}
return false;
}
public function update(FormModel $form_model, TgbotNotification $model): false|TgbotNotification
{
$model->bot_id = $form_model->getItem('bot_id');
$model->dialog_id = $form_model->getItem('dialog_id');
$model->to_group = $form_model->getItem('to_group');
$model->content = $form_model->getItem('content');
$model->photo = $form_model->getItem('photo');
$model->status = $form_model->getItem('status');
if ($model->save()){
return $model;
}
return false;
}
}