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' => 'Текст', ]; } public function fields(): array { return [ 'id', 'created_at', 'updated_at', 'user_id', 'user' => function () { return [ "fio" => $this->user->userCard->fio ?? $this->user->username, "avatar" => $this->user->userCard->photo ?? '', ]; }, 'parent_id', 'entity_type', 'entity_id', 'status', 'text', ]; } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id']); } /** * @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 => "Не активен", ]; } }