-
master/composer.json
Open in GitHub{ "require": { "php": "^7.3", // "laravolt/avatar": "^4" }, }
-
app/Http/Controllers/UserCoverController.php
Open in GitHubuse App\User; use Avatar; use Storage; class UserCoverController extends Controller { public function show(User $user, $size = 'medium') { $avatar_path = storage_path().'/app/users/'.$user->id.'/cover.jpg'; if (!File::exists($avatar_path)) { Storage::disk('local')->makeDirectory('users/'.$user->id); Avatar::create($user->name) ->setDimension(400, 400) ->setFontSize(200) ->save(storage_path().'/app/users/'.$user->id.'/generated_cover.png'); $avatar_path = storage_path().'/app/users/'.$user->id.'/generated_cover.png'; } // } }