1010use Illuminate \Database \Eloquent \ModelNotFoundException ;
1111
1212/**
13- * Class RenderFileController
13+ * Class RenderFileController.
1414 */
1515class RenderFileController extends Controller
1616{
@@ -38,6 +38,7 @@ public function show($uuid, Request $request)
3838 {
3939 try {
4040 $ model = $ this ->model ->byUuid ($ uuid )->firstOrFail ();
41+
4142 return $ this ->renderFile ($ model , $ request ->get ('width ' , null ), $ request ->get ('height ' , null ));
4243 } catch (ModelNotFoundException $ e ) {
4344 return $ this ->renderPlaceholder ($ request ->get ('width ' , null ), $ request ->get ('height ' , null ));
@@ -53,6 +54,7 @@ public function show($uuid, Request $request)
5354 public function renderFile ($ model , $ width , $ height )
5455 {
5556 $ image = $ this ->makeFromPath ($ width , $ height , $ model ->path );
57+
5658 return $ image ->response ();
5759 }
5860
@@ -63,11 +65,13 @@ public function renderFile($model, $width, $height)
6365 */
6466 public function renderPlaceholder ($ width , $ height )
6567 {
66- $ image = Image::cache (function ($ image ) use ($ width , $ height ){
68+ $ image = Image::cache (function ($ image ) use ($ width , $ height ) {
6769 $ img = $ image ->canvas (800 , 800 , '#FFFFFF ' );
6870 $ this ->resize ($ img , $ width , $ height );
71+
6972 return $ img ;
7073 }, 10 , true );
74+
7175 return $ image ->response ();
7276 }
7377
@@ -79,9 +83,10 @@ public function renderPlaceholder($width, $height)
7983 */
8084 protected function makeFromPath ($ width , $ height , $ path )
8185 {
82- return Image::cache (function ($ image ) use ($ path , $ width , $ height ){
86+ return Image::cache (function ($ image ) use ($ path , $ width , $ height ) {
8387 $ img = $ image ->make (Storage::get ($ path ));
8488 $ this ->resize ($ img , $ width , $ height );
89+
8590 return $ img ;
8691 }, 10 , true );
8792 }
@@ -105,6 +110,7 @@ protected function resize($img, $width, $height)
105110 $ constraint ->aspectRatio ();
106111 });
107112 }
113+
108114 return $ img ;
109115 }
110- }
116+ }
0 commit comments