From ec273d2928d04ff8850a0dfa2c123bc8f5705cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Bustos?= Date: Tue, 1 May 2018 12:28:47 -0300 Subject: [PATCH] Add getAvatarAttribute() refactoring other methods this will work --- app/Models/User.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Models/User.php b/app/Models/User.php index ed24aa81..3c70bc23 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -122,6 +122,20 @@ class User extends Authenticatable { $this->attributes['timezone'] = $value; } + + /** + * Return a File model + */ + public function getAvatarAttribute() + { + if (!$this->attributes['avatar']) { + return null; + } + + return new File([ + 'path' => $this->attributes['avatar'] + ]); + } /** * @param mixed $size Size of the gravatar, in pixels