Skip to content

Instantly share code, notes, and snippets.

@sehmbimanvir
Created March 21, 2019 11:48
Show Gist options
  • Save sehmbimanvir/3842e3ccc28c380ac0a286c712799ea1 to your computer and use it in GitHub Desktop.
Save sehmbimanvir/3842e3ccc28c380ac0a286c712799ea1 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use App\Image;
use App\Http\Requests\StoreImage;
use Illuminate\Support\Facades\Storage;
class ImageController extends Controller
{
private $image;
public function __construct(Image $image)
{
$this->image = $image;
}
public function getImages()
{
return view('images')->with('images', auth()->user()->images);
}
public function postUpload(StoreImage $request)
{
$path = Storage::disk('s3')->put('images/originals', $request->file);
$request->merge([
'size' => $request->file->getClientSize(),
'path' => $path
]);
$this->image->create($request->only('path', 'title', 'size'));
return back()->with('success', 'Image Successfully Saved');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment