Last active
September 4, 2019 11:01
Revisions
-
garyconstable revised this gist
Sep 4, 2019 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ <?php function store(Request $request) { $this->validateImage($request); -
garyconstable created this gist
Sep 4, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ public function store(Request $request) { $this->validateImage($request); $image = new Image(); $file = $request->file('file'); $image->original_file_name = 'original.'.$file->extension(); $image->thumbnail_file_name = 'thumbnail.'.$file->extension(); $image->save(); $disk = Image::disk(); // Upload the original image... $disk->putFileAs( $image->getBasePath(), $file, $image->original_file_name ); // Create and upload the thumbnail... $disk->put( $image->thumbnail_file_path, value(function () use ($file, $image, $disk) { return Manipulator::make($file)->fit(300, 300)->stream(); }) ); return new ImageResource($image); }