changeAvatarPath() public method

Change the path of the user avatar.
public changeAvatarPath ( string $path )
$path string
Example #1
0
 private function saveAvatarFromUrl(User $user, $url)
 {
     $tmpFile = tempnam($this->app->storagePath() . '/tmp', 'avatar');
     $manager = new ImageManager();
     $manager->make($url)->fit(100, 100)->save($tmpFile);
     $mount = new MountManager(['source' => new Filesystem(new Local(pathinfo($tmpFile, PATHINFO_DIRNAME))), 'target' => $this->uploadDir]);
     $uploadName = Str::lower(Str::quickRandom()) . '.jpg';
     $user->changeAvatarPath($uploadName);
     $mount->move("source://" . pathinfo($tmpFile, PATHINFO_BASENAME), "target://{$uploadName}");
 }