|
|
|
@ -125,13 +125,15 @@ class Profile extends Model
|
|
|
|
|
|
|
|
|
|
public function avatar()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(Avatar::class);
|
|
|
|
|
return $this->hasOne(Avatar::class)->withDefault([
|
|
|
|
|
'media_path' => 'public/avatars/default.png'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function avatarUrl()
|
|
|
|
|
{
|
|
|
|
|
$url = Cache::remember("avatar:{$this->id}", 1440, function() {
|
|
|
|
|
$path = $this->avatar->media_path ?? 'public/avatars/default.png';
|
|
|
|
|
$path = optional($this->avatar)->media_path;
|
|
|
|
|
$version = hash('sha1', $this->avatar->created_at);
|
|
|
|
|
$path = "{$path}?v={$version}";
|
|
|
|
|
return url(Storage::url($path));
|
|
|
|
|