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