public function actionDeleteFile($id) { $id = (int)$id; // check that you have access to this note $file = ArticleImages::model()->findByPk($id); if(isset($file->organization)){ // $pin = $this->_loadModel($file->pinboard->id); // remove it from disk also in model issueFile if($file->delete()) { echo "[]"; Yii::app()->end(); } } echo 'error'; Yii::app()->end(); }