guild/common/models/UserTgBotDialog.php

79 lines
1.7 KiB
PHP
Raw Permalink Normal View History

<?php
namespace common\models;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
/**
* This is the model class for table "user_tg_bot_dialog".
*
* @property int $id
* @property int $user_id
* @property int $dialog_id
* @property string $created_at
* @property string $updated_at
*
* @property User $user
*/
class UserTgBotDialog extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'user_tg_bot_dialog';
}
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
];
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['user_id', 'dialog_id'], 'integer'],
[['dialog_id'], 'required'],
[['created_at', 'updated_at'], 'safe'],
[['dialog_id'], 'unique'],
[['user_id'], 'unique'],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'dialog_id' => 'Dialog ID',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
}