/** * Upload a avatar image * @param obj $file * @param str $filename */ public function avatar_upload($file, $filename) { if ($file) { $newfilename = $filename . '.' . $file->getClientOriginalExtension(); $upload_dir = config('assets.images.paths.input'); //Get the width and the height of the chosen size from the Config file. $images_sizes = config('assets.images.sizes.' . 'small'); $width = $images_sizes['width']; $height = $images_sizes['height']; //Uploading picture to the directory $file->move($upload_dir, $newfilename); //Resizing picture $image = Image::make(sprintf($upload_dir . '/%s', $newfilename))->resize($width, $height)->save(); $avatar_path = $upload_dir . '/' . $newfilename; return $avatar_path; } }