1 <?php namespace BookStack\Uploads;
3 use Illuminate\Contracts\Filesystem\Factory as FileSystem;
4 use Illuminate\Contracts\Filesystem\Filesystem as FileSystemInstance;
6 abstract class UploadService
12 protected $fileSystem;
16 * FileService constructor.
19 public function __construct(FileSystem $fileSystem)
21 $this->fileSystem = $fileSystem;
25 * Get the storage that will be used for storing images.
26 * @return FileSystemInstance
28 protected function getStorage()
30 $storageType = config('filesystems.default');
31 return $this->fileSystem->disk($storageType);
35 * Check whether or not a folder is empty.
39 protected function isFolderEmpty($path)
41 $files = $this->getStorage()->files($path);
42 $folders = $this->getStorage()->directories($path);
43 return (count($files) === 0 && count($folders) === 0);