user_id = $userId; $review->parent_id = $parentId; $review->text = $text; $review->created_at = time(); $review->active = true; return $review; } public function edit($parentId, $text): void { $this->parent_id = $parentId; $this->text = $text; } public function attributeLabels() { return [ 'id' => Yii::t('post', 'ID'), 'user_id' => Yii::t('post', 'User'), 'parent_id' => Yii::t('post', 'Parent Comment ID'), 'created_at' => Yii::t('post', 'Created At'), 'active' => Yii::t('post', 'Published'), 'post_id' => Yii::t('post', 'Post'), 'text' => Yii::t('post', 'Comment'), ]; } public function activate(): void { $this->active = true; } public function draft(): void { $this->active = false; } public function isActive(): bool { return $this->active == true; } public function isIdEqualTo($id): bool { return $this->id == $id; } public function isChildOf($id): bool { return $this->parent_id == $id; } public function getPost(): ActiveQuery { return $this->hasOne(Post::class, ['id' => 'post_id']); } public function getUser(): ActiveQuery { return $this->hasOne(User::class, ['id' => 'user_id']); } public static function tableName(): string { return '{{%post_comments}}'; } }