Пример #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param Post $post
  * @return \Illuminate\View\View
  */
 public function edit(Post $post)
 {
     $thumbnail = $this->file->findFileByZoneForEntity('thumbnail', $post);
     $categories = $this->category->allTranslatedIn(app()->getLocale());
     $statuses = $this->status->lists();
     return view('blog::admin.posts.edit', compact('post', 'categories', 'thumbnail', 'statuses'));
 }
Пример #2
0
 public function unlink(Module $module, Request $request, FileRepository $fileRepository, Imagy $imagy)
 {
     DB::table('media__imageables')->whereFileId($request->get('fileId'))->delete();
     $file = $fileRepository->find($request->get('fileId'));
     $imagy->deleteAllFor($file);
     $fileRepository->destroy($file);
 }
Пример #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->line('Preparing to regenerate all thumbnails...');
     foreach ($this->file->all() as $file) {
         $this->imagy->createAll($file->path);
     }
     $this->info('All thumbnails refreshed');
 }
Пример #4
0
 public function linkMedia(Request $request)
 {
     $mediaId = $request->get('mediaId');
     $file = $this->file->find($mediaId);
     $path = $file->path->getUrl();
     $thumbnailPath = $this->imagy->getThumbnail($file->path, 'mediumThumb');
     return Response::json(['error' => false, 'message' => 'The link has been added.', 'result' => ['path' => $path, 'thumb' => $thumbnailPath]]);
 }
Пример #5
0
 /**
  * @param  UploadedFile $file
  * @return mixed
  */
 public function store(UploadedFile $file)
 {
     $savedFile = $this->file->createFromFile($file);
     $path = $this->getDestinationPath($savedFile->getOriginal('path'));
     $stream = fopen($file->getRealPath(), 'r+');
     $this->filesystem->disk($this->getConfiguredFilesystem())->writeStream($path, $stream, ['visibility' => 'public', 'mimetype' => $savedFile->mimetype]);
     $this->createThumbnails($savedFile);
     return $savedFile;
 }
Пример #6
0
 /**
  * @param  UploadedFile $file
  * @return mixed
  */
 public function store(UploadedFile $file)
 {
     // Save the file info to db
     try {
         $savedFile = $this->file->createFromFile($file);
     } catch (\InvalidArgumentException $e) {
         return $e->getMessage();
     }
     // Move the uploaded file to files path
     $file->move(public_path() . $this->config->get('asgard.media.config.files-path'), $savedFile->filename);
     @chmod(public_path() . $this->config->get('asgard.media.config.files-path') . $savedFile->filename, 0666);
     $this->createThumbnails($savedFile);
     return $savedFile;
 }
Пример #7
0
 /**
  * Link the given entity with a media file
  * @param Request $request
  */
 public function linkMedia(Request $request)
 {
     $mediaId = $request->get('mediaId');
     $entityClass = $request->get('entityClass');
     $entityId = $request->get('entityId');
     $entity = $entityClass::find($entityId);
     $zone = $request->get('zone');
     $entity->files()->attach($mediaId, ['imageable_type' => $entityClass, 'zone' => $zone]);
     $imageable = DB::table('media__imageables')->whereFileId($mediaId)->whereZone($zone)->whereImageableType($entityClass)->first();
     $file = $this->file->find($imageable->file_id);
     $thumbnailPath = $this->imagy->getThumbnail($file->path, 'mediumThumb');
     event(new FileWasLinked($file, $entity));
     return Response::json(['error' => false, 'message' => 'The link has been added.', 'result' => ['path' => $thumbnailPath, 'imageableId' => $imageable->id]]);
 }
Пример #8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  File     $file
  * @internal param int $id
  * @return Response
  */
 public function destroy(File $file)
 {
     $this->imagy->deleteAllFor($file);
     $this->file->destroy($file);
     flash(trans('media::messages.file deleted'));
     return redirect()->route('admin.media.media.index');
 }
Пример #9
0
 /**
  * Link the given entity with a media file
  *
  * @param Request $request
  */
 public function linkMedia(Request $request)
 {
     $mediaId = $request->get('mediaId');
     $entityClass = $request->get('entityClass');
     $entityId = $request->get('entityId');
     $order = $request->get('order');
     $entity = $entityClass::find($entityId);
     $zone = $request->get('zone');
     $entity->files()->attach($mediaId, ['imageable_type' => $entityClass, 'zone' => $zone, 'order' => $order]);
     $imageable = DB::table('media__imageables')->whereFileId($mediaId)->whereZone($zone)->whereImageableType($entityClass)->first();
     $file = $this->file->find($imageable->file_id);
     if (str_contains($file->mimetype, 'video')) {
         $thumbnailPath = $file->path->getRelativeUrl();
         $mediaType = 'video';
     } else {
         $thumbnailPath = $this->imagy->getThumbnail($file->path, 'mediumThumb');
         $mediaType = 'image';
     }
     event(new FileWasLinked($file, $entity));
     return Response::json(['error' => false, 'message' => 'The link has been added.', 'result' => ['path' => $thumbnailPath, 'imageableId' => $imageable->id, 'mediaType' => $mediaType]]);
 }
Пример #10
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  Recipe $recipe
  * @return Response
  */
 public function edit(Recipe $recipe)
 {
     $galleryFiles = $this->file->findMultipleFilesByZoneForEntity('gallery', $recipe);
     $featured_image = $this->file->findFileByZoneForEntity('featured_image', $recipe);
     return view('recipe::admin.recipes.edit', compact('recipe', 'galleryFiles', 'featured_image'));
 }
Пример #11
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->line('Preparing to regenerate all thumbnails...');
     $this->dispatch(new RebuildThumbnails($this->file->all()->pluck('path')));
     $this->info('All thumbnails refreshed');
 }
Пример #12
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  Podcast $podcast
  * @return Response
  */
 public function edit(Podcast $podcast, FileRepository $fileRepository)
 {
     $audioFile = $fileRepository->findFileByZoneForEntity('audioFile', $podcast);
     return view('podcast::admin.podcasts.edit', compact('podcast', 'audioFile'));
 }
Пример #13
0
 public function createGallery(Module $module, FileRepository $fileRepository)
 {
     $galleryImages = $fileRepository->findMultipleFilesByZoneForEntity('module_gallery', $module);
     $iconImage = $fileRepository->findMultipleFilesByZoneForEntity('module_icon', $module);
     return view('module::account.modules.createGallery', compact('module', 'galleryImages', 'iconImage'));
 }
Пример #14
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  Gallery $gallery
  * @return Response
  */
 public function edit(Gallery $gallery, FileRepository $fileRepository)
 {
     $image = $fileRepository->findFileByZoneForEntity('image', $gallery);
     return view('gallery::admin.galleries.edit', compact('gallery', 'image'));
 }
Пример #15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  Module $module
  * @return Response
  */
 public function destroy(Module $module, FileRepository $fileRepository, Imagy $imagy)
 {
     if ($module->images->count() > 0) {
         foreach ($module->images as $image) {
             \DB::table('media__imageables')->whereFileId($image->id)->delete();
             $file = $fileRepository->find($image->id);
             $imagy->deleteAllFor($file);
             $fileRepository->destroy($file);
         }
     }
     $this->module->destroy($module);
     flash()->success(trans('core::core.messages.resource deleted', ['name' => trans('module::modules.title.modules')]));
     return redirect()->route('admin.module.module.index');
 }
Пример #16
0
 /**
  * A grid view of uploaded files used for the wysiwyg editor
  * @return \Illuminate\View\View
  */
 public function ckIndex()
 {
     $files = $this->file->all();
     $thumbnails = $this->thumbnailsManager->all();
     return view('media::admin.grid.ckeditor', compact('files', 'thumbnails'));
 }
Пример #17
0
 /**
  *
  */
 private function emptyMedia()
 {
     foreach ($this->file->all() as $file) {
         $this->file->destroy($file);
     }
 }