File: //proc/1122/cwd/common/models/BotMessageSend.php
<?php
namespace common\models;
use trntv\filekit\behaviors\UploadBehavior;
use Yii;
/**
* This is the model class for table "bot_message_send".
*
* @property int $id
* @property string|null $task_name
* @property int|null $chat_id
* @property int|null $user_id
* @property int|null $bot_id
* @property int|null $bot_type
* @property int|null $bot_contacts_book_id
* @property string|null $file
* @property string|null $img
* @property string|null $message
* @property string|null $link_text
* @property string|null $link
* @property string|null $started_at
* @property int $status
*/
class BotMessageSend extends \yii\db\ActiveRecord
{
public $resource_file;
public $resource_image;
const WAITING = 0;
const IN_PROCESS = 1;
const SENDED = 2;
const CANCELLED = 3;
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'bot_message_send';
}
/**
* @return array
*/
public function behaviors()
{
return [
'file' => [
'class' => UploadBehavior::class,
'attribute' => 'resource_file',
'pathAttribute' => 'file',
],
'img' => [
'class' => UploadBehavior::class,
'attribute' => 'resource_image',
'pathAttribute' => 'img',
],
];
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['message'], 'required'],
[['chat_id', 'user_id', 'bot_id', 'bot_type', 'bot_contacts_book_id', 'status'], 'integer'],
[['task_name', 'file', 'img', 'link_text', 'link', 'started_at'], 'string', 'max' => 255],
[['message'], 'string', 'max' => 1500],
[['bot_id'], 'exist', 'skipOnError' => true, 'targetClass' => Bot::className(), 'targetAttribute' => ['bot_id' => 'id']],
[['bot_contacts_book_id'], 'exist', 'skipOnError' => true, 'targetClass' => BotContactBooks::className(), 'targetAttribute' => ['bot_contacts_book_id' => 'id']],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
[['resource_image', 'resource_file'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => Yii::t('common', 'ID'),
'task_name' => Yii::t('common', 'Task Name'),
'chat_id' => Yii::t('common', 'Chat ID'),
'user_id' => Yii::t('common', 'User ID'),
'bot_id' => Yii::t('common', 'Bot ID'),
'bot_type' => Yii::t('common', 'Bot Type'),
'bot_contacts_book_id' => Yii::t('common', 'Bot Contacts Book ID'),
'file' => Yii::t('common', 'File'),
'img' => Yii::t('common', 'Img'),
'message' => Yii::t('common', 'Message'),
'link_text' => Yii::t('common', 'Link Text'),
'link' => Yii::t('common', 'Link'),
'started_at' => Yii::t('common', 'Started At'),
'status' => Yii::t('common', 'Status'),
];
}
/**
* Gets query for [[Bot]].
*
* @return \yii\db\ActiveQuery
*/
public function getBot()
{
return $this->hasOne(Bot::className(), ['id' => 'bot_id']);
}
/**
* Gets query for [[BotContactsBook]].
*
* @return \yii\db\ActiveQuery
*/
public function getBotContactsBook()
{
return $this->hasOne(BotContactBooks::className(), ['id' => 'bot_contacts_book_id']);
}
/**
* Gets query for [[User]].
*
* @return \yii\db\ActiveQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
}