joelbutcher / socialstream

OAuth for Laravel, simplified.

Home Page:https://docs.socialstream.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] Wrong cast type

DubStepMad opened this issue · comments

Describe the bug
After following the v4.x upgrade guide I am presented with the following error:
htmlspecialchars(): Argument #1 ($string) must be of type string, Illuminate\Database\Eloquent\Casts\Attribute given

Now the new method profilePhotoUrl is called in blade like this: {{ Auth::user()->profilePhotoUrl() }} which is throwing the error.

User Model Method:

/**
 * Get the URL to the user's profile photo.
 *
 */
public function profilePhotoUrl(): Attribute
{
    return filter_var($this->profile_photo_path, FILTER_VALIDATE_URL)
        ? Attribute::get(fn() => $this->profile_photo_path)
        : $this->getPhotoUrl();
}

To Reproduce
Steps to reproduce the behavior:

  1. Follow upgrade guide from v3 to v4

Expected behavior
For the avatar to be displayed as previously it did.

Environment context

  • Socialstream version: 4.1.3
  • Jetstream stack: Livewire
  • Laravel version: 10.20.0
  • PHP version: 8.2

Little digging around and try this instead in the User Model and works as intended.

Not sure if is something to do with versions, but the Jetstream version I have is: v3.3.3

/**
 * Get the URL to the user's profile photo.
 *
 */
public function profilePhotoUrl()
{
    return $this->profile_photo_path
        ? Storage::disk($this->profilePhotoDisk())->url($this->profile_photo_path)
        : $this->defaultProfilePhotoUrl();
}

@DubStepMad can you change the code in the blade file to {{ Auth::user()->profile_photo_url }} to see if this fixes the issue for you? AFAIK that's what the originally Jetstream templates should be using in v3.3.3 and v4.x of Socialstream