/**
  * Method for deleting media assigned to this
  */
 public function actionDelmedia($id)
 {
     $model = PestPhoto::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $model->delete();
 }
Beispiel #2
0
 /**
  * Create images for this article.
  */
 public function createImage()
 {
     $thumb = Yii::app()->phpThumb->create($this->image->getTempName());
     $thumb->resize(600, 600);
     $path = Yii::app()->params['projectPath'] . Yii::app()->params['imagePath'];
     $thumb->save($path . $this->imageName . '.jpg', 'jpg');
     // Add this image to the db.
     $pic = new Photo();
     $pic->Name = $this->imageName . '.jpg';
     if ($pic->save()) {
         // Create new linker.
         $picLinker = new PestPhoto();
         $picLinker->PestId = $this->Id;
         $picLinker->PhotoId = $pic->Id;
         $picLinker->save();
     }
 }