/** * Handle the command. * * @param FileRepositoryInterface $files * @param FolderRepositoryInterface $folders */ public function handle(FileRepositoryInterface $files, FolderRepositoryInterface $folders) { $folder = $folders->findBySlug(dirname($this->file->getPath())); $file = $files->findByNameAndFolder(basename($this->file->getPath()), $folder); if ($file) { $files->delete($file); } }
/** * Handle the command. * * @param FileRepositoryInterface $files */ public function handle(FileRepositoryInterface $files) { foreach ($this->folder->getFiles() as $file) { if ($this->folder->isForceDeleting()) { $files->forceDelete($file); } else { $files->delete($file); } } }
/** * Fire just before saving a folder. * * @param EntryInterface|FolderInterface $entry */ public function deleting(EntryInterface $entry) { $this->manager->deleteDir($entry->diskPath()); // Delete contained files. foreach ($entry->getFiles() as $file) { $this->files->delete($file); } // Delete contained folders. foreach ($entry->getChildren() as $folder) { $this->folders->delete($folder); } }
/** * Fire the command. * * @param FileRepositoryInterface $files */ public function fire(FileRepositoryInterface $files) { $missing = false; /* @var FileInterface|EloquentModel $file */ foreach ($files->all() as $file) { if (!$file->resource()) { $missing = true; if (!$this->option('pretend')) { $files->delete($file); } $this->info($file->path() . ' ' . (!$this->option('pretend') ? 'deleted' : 'missing') . '.'); } } if (!$missing) { $this->info('Files database is clean.'); } }
/** * Handle the command. * * @param FileRepositoryInterface $files */ public function handle(FileRepositoryInterface $files) { foreach ($this->folder->getFiles() as $file) { $files->delete($file); } }