43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?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;
|
|
}
|
|
|
|
} |