public static function moveAndCreateImages($galleryID) { if (!self::isDirectoryEmpty(self::$imgpath)) { foreach (scandir(self::$imgpath) as $img) { if (!is_dir($img)) { GalleryAddView::uploadImage($img, self::$imgpath . $img); } } } foreach (GalleryAddView::$createdImagesForGallery as $id) { $image = new Image($id); $image->GalleryID = $galleryID; $image->save(); } }