app\controllers\CashbookController::actionDelete PHP Method

actionDelete() public method

public actionDelete ( $id )
    public function actionDelete($id)
    {
        $model = $this->findModel($id);
        if ($model->user_id != Yii::$app->user->id) {
            throw new ErrorException(Yii::t('app', 'Forbidden to change entries of other users'));
        }
        // validate deletion and on failure process any exception
        // e.g. display an error message
        if ($model->delete()) {
            if (!$model->deleteImage()) {
                Yii::$app->session->setFlash("Entry-danger", 'Error deleting image');
            }
        }
        Yii::$app->session->setFlash("Entry-success", Yii::t("app", "Entry successfully deleted"));
        return $this->redirect(['index']);
    }