/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = $this->createUser();
     $video = new Video();
     $video->name = 'demo';
     $video->category = 'Movie';
     $video->path = Storage::url('videos/demo');
     $user->getVideos()->save($video);
 }
示例#2
0
 /**
  * @param $file
  *
  * @return Document
  * @throws \Exception
  */
 public function handleSingleFile($file)
 {
     if (!$file instanceof UploadedFile) {
         throw new \Exception("Dados inválidos para upload");
     }
     $document = $this->createDocument($file);
     $this->processBeforeSave($document);
     $disk = Storage::disk()->getDriver();
     $disk->put($document->filePath, fopen($file, 'r+'), ['visibility' => 'public', 'ContentType' => $document->mimeType]);
     $document->url = config('filesystems.default') == 'public' ? asset('images/' . $document->filePath) : Storage::url($document->filePath);
     $document->save();
     $this->addFileToList($document);
     return $document;
 }
 /**
  * Store a newly created video in storage.
  *
  * @param VideoUploadRequest $request
  *
  * @return mixed
  */
 public function store(VideoUploadRequest $request)
 {
     $user = $this->user->authenticated();
     $file = $request->video;
     $nameFile = str_replace(' ', '', $request->input('name') . $user->id);
     $data = ['name' => $request->input('name'), 'category' => $request->input('category'), 'path' => Storage::url('videos/' . $nameFile), 'user_id' => $user->id];
     $video = $this->video->create($data);
     $this->saveAndConvert($file, $nameFile);
     return $this->response->withItem($video, $this->videoTransformer);
 }
 /**
  * Store image avatar.
  *
  * @param $image
  * @param $user
  *
  * @return mixed
  */
 private function storeImage($image, $user)
 {
     $path = Storage::url('images/avatars/' . $user->id . '.' . $image->getClientOriginalExtension());
     Storage::disk('public')->put('images/avatars/' . $user->id . '.' . $image->getClientOriginalExtension(), file_get_contents($image->getRealPath()));
     return $path;
 }
 public static function getUrl($filename)
 {
     return Storage::url(self::setEnvironment() . $filename);
 }