/** * Handles a comment model when submitted * * @param \asinfotrack\yii2\comments\models\Comment $model * @return bool true if created * @throws \yii\db\Exception */ public static function handle($model) { if (!$model->load(Yii::$app->request->post())) { return false; } return $model->save(); }
/** * Returns the number of comments the subject has * * @return int|string */ public function getNumComments() { return Comment::find()->subject($this->owner)->count(); }