48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace kernel\app_modules\tgbot\services;
|
||
|
|
||
|
use app\modules\tgbot\models\Tgbot;
|
||
|
use kernel\app_modules\tag\models\Tag;
|
||
|
use kernel\FormModel;
|
||
|
use kernel\helpers\Debug;
|
||
|
use kernel\helpers\Slug;
|
||
|
use kernel\services\ModuleService;
|
||
|
|
||
|
class TgBotService
|
||
|
{
|
||
|
public function create(FormModel $form_model): false|Tgbot
|
||
|
{
|
||
|
$model = new Tgbot();
|
||
|
$model->bot_id = $form_model->getItem('bot_id');
|
||
|
$model->dialog_id = $form_model->getItem('dialog_id');
|
||
|
$model->user_id = $form_model->getItem('user_id');
|
||
|
$model->username = $form_model->getItem('username');
|
||
|
$model->first_name = $form_model->getItem('first_name');
|
||
|
$model->last_name = $form_model->getItem('last_name');
|
||
|
$model->status = $form_model->getItem('status');
|
||
|
if ($model->save()){
|
||
|
return $model;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public function update(FormModel $form_model, Tgbot $model): false|Tgbot
|
||
|
{
|
||
|
$model->bot_id = $form_model->getItem('bot_id');
|
||
|
$model->dialog_id = $form_model->getItem('dialog_id');
|
||
|
$model->user_id = $form_model->getItem('user_id');
|
||
|
$model->username = $form_model->getItem('username');
|
||
|
$model->first_name = $form_model->getItem('first_name');
|
||
|
$model->last_name = $form_model->getItem('last_name');
|
||
|
$model->status = $form_model->getItem('status');
|
||
|
|
||
|
if ($model->save()){
|
||
|
return $model;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|