frontend/controllers/CommentController.php
/**
     * Creates a new Comment model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Comment model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Comment model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $comment = new Comment();
        $comment->text = Yii::$app->request->post()['text'];
        $comment->user_id = Yii::$app->user->id;
        $temp = $_SERVER['HTTP_REFERER'];
        $temp = explode('/',$temp);
        $comment->post_id = end($temp);
        $comment->save();
        return $this->redirect(Yii::$app->request->referrer);
    }
public function actionCreate ( ) { $ comment = new Comment ( ) ; $ comment -> text = Yii :: $ app -> request -> post ( ) [ 'text' ] ; $ comment -> user_id = Yii :: $ app -> user -> id ; $ temp = $ _SERVER [ 'HTTP_REFERER' ] ; $ temp = explode ( '/' , $ temp ) ; $ comment -> post_id = end ( $ temp ) ; $ comment -> save ( ) ; return $ this -> redirect ( Yii :: $ app -> request -> referrer ) ; }
Creates a new Comment model.
Creates a new Comment model .