Created
March 21, 2019 11:48
-
-
Save sehmbimanvir/3842e3ccc28c380ac0a286c712799ea1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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