Example #1
0
 /**
  * AJAX
  * Оставляет комментарий в статье
  *
  * @return string
  * {
  *      text: str,
  *      user: {
  *              id: int,
  *              name: str,
  *              avatar: str,
  *            }
  * }
  */
 public function actionSend()
 {
     $type_id = self::getParam('type_id');
     $row_id = self::getParam('row_id');
     $content = self::getParam('Form')['content'];
     Model::insert(['type_id' => $type_id, 'row_id' => $row_id, 'content' => $content, 'user_id' => Yii::$app->user->getId()]);
     (new \app\modules\Comment\Cache(['typeId' => $type_id, 'rowId' => $row_id]))->clear();
     return self::jsonSuccess(['text' => $content, 'user' => (new UsersInCache())->getUserData(Yii::$app->user->identity)]);
 }