Esempio n. 1
0
 /**
  * Locate a file by disk and path.
  *
  * @param $disk
  * @param $path
  * @return FileInterface|null
  */
 public function locate($disk, $path)
 {
     if (!($disk = $this->disks->findBySlug($disk))) {
         return null;
     }
     $folder = dirname($path) !== '.' ? $this->folders->findByPath(dirname($path), $disk) : null;
     if (!($file = $this->files->findByName(basename($path), $disk, $folder))) {
         return null;
     }
     return $file;
 }
 public function migrate(Request $request, MessageBag $bag, FolderRepositoryInterface $folders)
 {
     $input = $request->input();
     if (!$input['table'] || !$input['column']) {
         $bag->error("Table and column are both required");
         return redirect('/admin/migrator/migrate_column');
     }
     $data = DB::select('select `id`, ' . $input['column'] . ' from ' . $input['table']);
     echo "<table><thead><tr><th>Row</th><th>Original ID</th><th>New Id</th></tr></thead><tbody>";
     foreach ($data as $row) {
         $remoteFile = json_decode($this->getData($this->baseUrl . '/migrator/get_file/' . $row->{$input['column']}));
         $folder = $folders->findByPath($remoteFile->path, $this->disk);
         $foundFile = false;
         if ($folder) {
             foreach ($folder->getFiles() as $file) {
                 if ($file->getName() == $remoteFile->file) {
                     $foundFile = true;
                     // return 'found file ID: ' . $file->getId();
                     echo "<tr><td>" . $row->id . "</td><td>" . $row->{$input['column']} . "</td><td>" . $file->getId() . "</td>";
                 }
             }
         }
         if (!$foundFile) {
             echo "<tr><td>" . $row->id . "</td><td>" . $row->{$input['column']} . "</td><td>Could not find file to migrate to.<br>";
             echo "<b>Path:</b> " . $remoteFile->path . "<br>";
             echo "<b>File:</b> " . $remoteFile->file . "<br>";
             echo "<b>Filename:</b> " . $remoteFile->filename;
             echo "</td></tr>";
         }
     }
     echo "</tbody></table>";
     var_dump($input['table']);
     var_dump($input['column']);
 }
 /**
  * Return a form to create a new folder.
  *
  * @param FolderFormBuilder $form
  * @param                   $path
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function create(FolderFormBuilder $form, DiskRepositoryInterface $disks, FolderRepositoryInterface $folders, $disk, $path = null)
 {
     $form->setDisk($disk = $disks->findBySlug($disk));
     if ($path && ($parent = $folders->findByPath($path, $disk))) {
         $form->setParent($parent);
     }
     return $form->render();
 }
Esempio n. 4
0
 /**
  * Return the form to upload files.
  *
  * @param FolderRepositoryInterface $folders
  * @param DiskRepositoryInterface   $disks
  * @param FileFormBuilder           $form
  * @param                           $disk
  * @param null                      $path
  * @return Response
  */
 public function upload(FolderRepositoryInterface $folders, DiskRepositoryInterface $disks, FileFormBuilder $form, $disk, $path = null)
 {
     $form->setDisk($disk = $disks->findBySlug($disk));
     if ($path && ($folder = $folders->findByPath($path, $disk))) {
         $form->setFolder($folder);
     }
     return $form->render();
 }
Esempio n. 5
0
 /**
  * Handle the command.
  *
  * @param FolderRepositoryInterface $folders
  * @return FolderInterface|bool
  */
 public function handle(FolderRepositoryInterface $folders)
 {
     $folder = $folders->findByPath($this->directory->getPath(), $this->getFilesystemDisk());
     if ($folder && $folders->delete($folder)) {
         return $folder;
     }
     return true;
 }
 /**
  * Return the details of a file or folder.
  *
  * @param $disk
  * @param $path
  * @return string
  */
 public function view($disk, $path)
 {
     $disk = $this->disks->findBySlug($disk);
     $folder = $this->folders->findByPath(dirname($path), $disk);
     $file = $this->files->findByName(basename($path), $disk, $folder);
     if (!$disk || !$folder && !$file) {
         abort(404);
     }
     if ($file) {
         return json_encode($file);
     }
     if ($folder) {
         return json_encode($folder);
     }
 }