public function actionDelete($id)
    {
        if (!Yii::$app->user->isGuest) {
            if (!empty($id)) {
                $viewedProduct = ViewedProduct::find()
                    ->where(['product_id' => $id, 'user_id' => Yii::$app->user->id])->one();
                if ($viewedProduct->user_id == Yii::$app->user->id) {
                    $viewedProduct->delete();
                    return $this->redirect(['list']);
                }
            }
        } else throw new NotFoundHttpException();
    }
public function actionDelete($id)
    {
        if (!Yii::$app->user->isGuest) {
            if (!empty($id)) {
                $viewedProduct = ViewedProduct::find()
                    ->where(['product_id' => $id, 'user_id' => Yii::$app->user->id])->one();
                if ($viewedProduct->user_id == Yii::$app->user->id) {
                    $viewedProduct->delete();
                    return $this->redirect(['list']);
                }
            }
        } else throw new NotFoundHttpException();
    }
public function actionDelete ( $ id ) { if ( ! Yii :: $ app -> user -> isGuest ) { if ( ! empty ( $ id ) ) { $ viewedProduct = ViewedProduct :: find ( ) -> where ( [ 'product_id' => $ id , 'user_id' => Yii :: $ app -> user -> id ] ) -> one ( ) ; if ( $ viewedProduct -> user_id == Yii :: $ app -> user -> id ) { $ viewedProduct -> delete ( ) ; return $ this -> redirect ( [ 'list' ] ) ; } } } else throw new NotFoundHttpException ( ) ; }
Deletes an existing ViewedProduct model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return \yii\web\Response
@throws NotFoundHttpException
Deletes an existing ViewedProduct model . If deletion is successful the browser will be redirected to the index page .