/** * Locate a file by disk and path. * * @param $folder * @param $path * @return FileInterface|null */ public function locate($folder, $name) { $folder = $this->folders->findBySlug($folder); if (!($file = $this->files->findByNameAndFolder($name, $folder))) { return null; } return $file; }
/** * Sync a file. * * @param Directory $resource * @param DiskInterface $disk * @return null|FolderInterface */ public function sync(Directory $resource, DiskInterface $disk) { $path = $resource->getPath(); if ($path === '.') { return null; } if (!($folder = $this->folders->findBySlug($path))) { $folder = $this->folders->create(['name' => $path, 'disk_id' => $disk->getId()]); } return $folder; }
/** * Return the form to upload files. * * @param FolderRepositoryInterface $folders * @param UploadTableBuilder $table * @param $folder * @return \Symfony\Component\HttpFoundation\Response */ public function index(FolderRepositoryInterface $folders, UploadTableBuilder $table, $folder) { $folder = $folders->findBySlug($folder); $table->make(); $table = $table->getTable(); return $this->view->make('module::admin/upload/index', compact('folder', 'table')); }
/** * 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 FolderRepositoryInterface $folders * @return FolderInterface|bool */ public function handle(FolderRepositoryInterface $folders) { $folder = $folders->findBySlug($this->directory->getPath(), $this->getFilesystemDisk()); if ($folder && $folders->delete($folder)) { return $folder; } return true; }
/** * Sync the files folder. * * @param File $resource * @param DiskInterface $disk * @return null|FolderInterface */ protected function syncFolder(File $resource, DiskInterface $disk) { $path = dirname($resource->getPath()); if ($path === '.') { return null; } /* @var FolderInterface|null $parent */ $parent = null; $folder = null; foreach (explode('/', $path) as $name) { if (!($folder = $this->folders->findBySlug($name))) { $folder = $this->folders->create(['name' => $name, 'disk_id' => $disk->getId(), 'parent_id' => $parent ? $parent->getId() : null]); } $parent = $folder; } return $folder; }
/** * Handle the command. * * @param FolderRepositoryInterface $folders * @param Decorator $decorator * @return null|FolderPresenter */ public function handle(FolderRepositoryInterface $folders, Decorator $decorator) { if (is_numeric($this->identifier)) { return $decorator->decorate($folders->find($this->identifier)); } if (is_string($this->identifier)) { return $decorator->decorate($folders->findBySlug($this->identifier)); } return null; }
/** * Handle the command. * * @param FileRepositoryInterface $files * @param FolderRepositoryInterface $folders * @param Decorator $decorator * @return \Anomaly\FilesModule\Folder\Contract\FolderInterface|\Anomaly\Streams\Platform\Model\EloquentModel|null */ public function handle(FolderRepositoryInterface $folders) { if (is_numeric($this->identifier)) { return $folders->find($this->identifier); } if (!is_numeric($this->identifier)) { return $folders->findBySlug($this->identifier); } return null; }
/** * Handle the command. * * @param FileRepositoryInterface $files * @param FolderRepositoryInterface $folders * @param Decorator $decorator * @return \Anomaly\FilesModule\File\Contract\FileInterface|\Anomaly\Streams\Platform\Model\EloquentModel|null */ public function handle(FileRepositoryInterface $files, FolderRepositoryInterface $folders) { if (is_numeric($this->identifier)) { return $files->find($this->identifier); } if (!is_numeric($this->identifier)) { list($folder, $name) = explode('/', $this->identifier); if (!($folder = $folders->findBySlug($folder))) { return null; } return $files->findByNameAndFolder($name, $folder); } return null; }