guild/common/models/Comment.php
2023-05-12 02:12:43 +03:00

105 lines
2.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
/**
* This is the model class for table "comment".
*
* @property int $id
* @property string $created_at
* @property string $updated_at
* @property int $user_id
* @property int $parent_id
* @property int $entity_type
* @property int $entity_id
* @property int $status
* @property string $text
*/
class Comment extends \yii\db\ActiveRecord
{
const ENTITY_TYPE_PROJECT = 1;
const ENTITY_TYPE_TASK = 2;
const STATUS_ACTIVE = 1;
const STATUS_DISABLE = 0;
/**
* @return array[]
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
];
}
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'comment';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['created_at', 'updated_at'], 'safe'],
[['user_id', 'parent_id', 'entity_type', 'entity_id', 'status'], 'integer'],
[['text'], 'string'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'created_at' => 'Дата создания',
'updated_at' => 'Дата редактирования',
'user_id' => 'Автор',
'parent_id' => 'Родительский',
'entity_type' => 'Сущность',
'entity_id' => 'Идентификатор сущности',
'status' => 'Статус',
'text' => 'Текст',
];
}
/**
* @return string[]
*/
public static function getEntityTypeList(): array
{
return [
self::ENTITY_TYPE_PROJECT => "Проект",
self::ENTITY_TYPE_TASK => "Задача",
];
}
/**
* @return string[]
*/
public static function getStatusList(): array
{
return [
self::STATUS_ACTIVE => "Активен",
self::STATUS_DISABLE => "Не активен",
];
}
}