예제 #1
0
 protected function loadState($id)
 {
     if (($productPhoto = ProductPhoto::findOne($id)) !== null) {
         return $productPhoto;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #2
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;
 }