Skip to content

[3.x] Convert Profile Photo URL attribute to newer syntax #1237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/HasProfilePhoto.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Laravel\Jetstream;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -55,13 +56,15 @@ public function deleteProfilePhoto()
/**
* Get the URL to the user's profile photo.
*
* @return string
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
public function getProfilePhotoUrlAttribute()
public function profilePhotoUrl(): Attribute
{
return $this->profile_photo_path
return Attribute::get(function () {
return $this->profile_photo_path
? Storage::disk($this->profilePhotoDisk())->url($this->profile_photo_path)
: $this->defaultProfilePhotoUrl();
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Livewire/DeleteUserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function deleteUser(Request $request, DeletesUsers $deleter, StatefulGuar
$request->session()->regenerateToken();
}

return redirect(config('fortify.redirects.logout', '/'));
return redirect(config('fortify.redirects.logout') ?? '/');
}

/**
Expand Down