/**
  * Upload a file.
  *
  * @param  FileUploader                  $uploader
  * @param  FolderRepositoryInterface     $folders
  * @return \Illuminate\Http\JsonResponse
  */
 public function upload(FileUploader $uploader, FolderRepositoryInterface $folders)
 {
     if ($file = $uploader->upload($this->request->file('upload'), $folders->find($this->request->get('folder')))) {
         return $this->response->json($file->getAttributes());
     }
     return $this->response->json(['error' => 'There was a problem uploading the file.'], 500);
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 /**
  * Handle the upload.
  *
  * @param FileUploader $uploader
  * @param FolderRepositoryInterface $folders
  * @return \Illuminate\Http\JsonResponse
  */
 public function upload(FileUploader $uploader, FolderRepositoryInterface $folders)
 {
     $error = trans('anomaly.module.files::error.generic');
     try {
         if ($file = $uploader->upload($this->request->file('upload'), $folders->find($this->request->get('folder')))) {
             return $this->response->json($file->getAttributes());
         }
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     return $this->response->json(['error' => $error], 500);
 }
Пример #5
0
 /**
  * Return a form for an existing file type field and assignment.
  *
  * @param AssignmentFormBuilder       $form
  * @param FolderRepositoryInterface   $folders
  * @param                             $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function assignment(AssignmentFormBuilder $form, FolderRepositoryInterface $folders, $id, $assignment)
 {
     $folder = $folders->find($id);
     $this->breadcrumbs->put('streams::breadcrumb.assignments', 'admin/files/types/assignments/' . $folder->getId());
     return $form->render($assignment);
 }