From bd685cf6f2d764ed135727a3075c35bf2a5944e3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 9 Oct 2018 19:25:27 -0600 Subject: [PATCH] Update Profile model, fix avatar caching bug --- app/Profile.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Profile.php b/app/Profile.php index b69bf74b9..4fe81c033 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -23,7 +23,7 @@ class Profile extends Model 'private_key', ]; - protected $visible = ['id', 'username', 'name']; + protected $visible = ['username', 'name']; public function user() { @@ -51,6 +51,10 @@ class Profile extends Model public function emailUrl() { + if($this->domain) { + return $this->username; + } + $domain = parse_url(config('app.url'), PHP_URL_HOST); return $this->username.'@'.$domain; @@ -137,7 +141,7 @@ class Profile extends Model { $url = Cache::remember("avatar:{$this->id}", 1440, function () { $path = optional($this->avatar)->media_path; - $version = hash('sha1', $this->avatar->created_at); + $version = hash('sha1', $this->avatar->updated_at); $path = "{$path}?v={$version}"; return url(Storage::url($path));