Update Profile model, fix avatar caching bug

This commit is contained in:
Daniel Supernault 2018-10-09 19:25:27 -06:00
parent 64f1118883
commit bd685cf6f2
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 6 additions and 2 deletions

View File

@ -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));