protected function loadState($id)
 {
     if (($productPhoto = ProductPhoto::findOne($id)) !== null) {
         return $productPhoto;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProductPhotos()
 {
     return $this->hasMany(ProductPhoto::className(), ['product_id' => 'id']);
 }
Beispiel #3
0
 protected static function deletePhoto($id, $uploadedPath)
 {
     if ($photo = ProductPhoto::findOne(['id' => $id])) {
         if (file_exists($path = $uploadedPath . $photo->photo)) {
             unlink($path);
             $photo->delete();
             return true;
         }
     }
     return false;
 }