/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ProductImageRequest $request, $id)
 {
     $file = $request->file('image');
     $extension = $file->getClientOriginalExtension();
     $image = $this->image->create(['product_id' => $id, 'extension' => $extension]);
     Storage::disk('local_public')->put($image->id . '.' . $extension, File::get($file));
     return redirect()->route('admin.images.index', $id);
 }
 public function images_store(Requests\ProductImageRequest $request, $id, ProductImages $productimage)
 {
     $file = $request->file('image');
     $extension = $file->getClientOriginalExtension();
     $image = $productimage::create(['product_id' => $id, 'extension' => $extension]);
     Storage::disk('publiclocal')->put($image->id . '.' . $extension, File::get($file));
     return redirect()->route('products.images', ['id' => $id]);
 }
 public function storeImage(ProductImageRequest $request, $id, ProductImage $productImage)
 {
     $file = $request->file('image');
     $extension = $file->getClientOriginalExtension();
     // Pega a extensão original do arquivo
     $image = $productImage::create(['product_id' => $id, 'extension' => $extension]);
     Storage::disk('public_local')->put($image->id . '.' . $extension, File::get($file));
     return redirect()->route('product.images', ['id' => $id]);
 }
 public function storeImages(Requests\ProductImageRequest $request, Product $product, ProductImage $productImage)
 {
     $image = $request->file('image');
     $productImage = $productImage::create(['product_id' => $product->id, 'extension' => $image->getClientOriginalExtension()]);
     Storage::disk('public_local')->put($productImage->imageName, file_get_contents($image));
     $thumb = Image::make(public_path('uploads') . '/' . $productImage->imageName)->resize(100, null, function ($a) {
         $a->aspectRatio();
     });
     $thumb->save(public_path('uploads/thumb') . '/' . $productImage->imageName);
     //Serviço Amazon S3
     //Storage::disk('s3')->put(
     //        'uploads/'.$productImage->id.'.'.$productImage->extension,
     //       file_get_contents($image),
     //       'public'
     //);
     //$image->move(public_path('upload'),$imageName);
     return redirect()->route('products.images', $product->id);
 }
 /**
  * salvar imagem de produto
  */
 public function storeImage(Requests\ProductImageRequest $request, $id, ProductImage $productImage)
 {
     $file = $request->file('image');
     // var_dump($file); exit();
     $extension = $file->getClientOriginalExtension();
     $image = $productImage::create(['product_id' => $id, 'extension' => $extension]);
     //gravar no banco
     //var_dump($image);exit();
     //gravar no disco config/filesystem.php
     Storage::disk('public_local')->put($image->id . '.' . $extension, File::get($file));
     return redirect()->route('admin.products_images.index', $id);
 }
 public function storeImage(Requests\ProductImageRequest $request, $id, ProductImage $productImage)
 {
     // guardo imagem do form na variável $file
     $file = $request->file('image');
     // metodo que pega a extensão original do arquivo
     $extension = $file->getClientOriginalExtension();
     // gravo no banco de dados o id do produto e a extensão através da instancia productImage
     $image = $productImage::create(['product_id' => $id, 'extension' => $extension]);
     // Utilizando a Facade Storage eu insiro a imagem no disco public_local, criado por mim no arquivo config/filesystems.php.
     // nesse caso, as imagens são inseridas na pasta public/uploads
     Storage::disk('public_local')->put($image->id . '.' . $extension, File::get($file));
     return redirect()->route('admin.products.images', ['id' => $id]);
 }
 public function storeImage($id, Requests\ProductImageRequest $request, ProductImage $productImage)
 {
     $file = $request->file('photo');
     // if(input::file('photo')->isValid()){
     $extension = Input::file('photo')->getClientOriginalExtension();
     $image = $productImage::create(['product_id' => $id, 'extension' => $extension]);
     Storage::disk('public_local')->put($image->id . '.' . $extension, File::get($file));
     return redirect()->route('products.images', ['id' => $id]);
     // }else{
     //   echo "algo está errado";
     //        /}
 }
 public function storeImage(Requests\ProductImageRequest $request, $id, ProductImage $productImage, \Illuminate\Contracts\Filesystem\Factory $storage, \Illuminate\Filesystem\Filesystem $fileSystem)
 {
     $file = $request->file('image');
     $extension = $file->getClientOriginalExtension();
     $image = $productImage::create(['product_id' => $id, 'extension' => $extension]);
     $storage->disk('public_local')->put($image->id . '.' . $extension, $fileSystem->get($file));
     return redirect()->route('admin.products.images.index', ['id' => $id]);
 }