public static function deleteImage($userId) { $model = UserBuilderProfile::model()->find('user_id=:userId', array(':userId' => $userId)); if ($model) { $image = $model->image; $imageFile = self::getImagesDirectory($userId) . $image; $success = Yii::app()->s3->deleteObject(Yii::app()->params['s3BucketName'], $imageFile); if ($success) { return true; } else { return false; } } return false; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = UserBuilderProfile::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }