Add a column for the user avatar #226

This commit is contained in:
Nabeel Shahzad
2018-04-02 06:47:31 -05:00
parent bb73af3806
commit f84ff8de92
2 changed files with 17 additions and 2 deletions

View File

@@ -15,7 +15,7 @@ use Laratrust\Traits\LaratrustUserTrait;
* @property string $email
* @property string $password
* @property string $api_key
* @property string current_airport_id
* @property string curr_airport_id
* @property string home_airport_id
* @property Flight[] $flights
* @property string $flight_time
@@ -56,7 +56,7 @@ class User extends Authenticatable
'flights',
'flight_time',
'transferred_time',
'balance',
'avatar',
'timezone',
'state',
'status',
@@ -123,6 +123,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
* @return string