user management v1.6-alpha.1

This commit is contained in:
carodej
2020-05-27 10:22:33 +02:00
parent 143aca64dc
commit a76d1dec3b
54 changed files with 3489 additions and 535 deletions
+26 -2
View File
@@ -63,7 +63,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'avatar',
'name', 'email', 'password', 'avatar', 'role',
];
/**
@@ -86,9 +86,23 @@ class User extends Authenticatable
];
protected $appends = [
'used_capacity'
'used_capacity', 'storage'
];
/**
* Get user used storage details
*
* @return mixed
*/
public function getStorageAttribute() {
return [
'used' => (float) get_storage_fill_percentage($this->used_capacity, $this->settings->storage_capacity),
'capacity' => $this->settings->storage_capacity,
'capacity_formatted' => Metric::gigabytes($this->settings->storage_capacity)->format(),
];
}
/**
* Get user used storage capacity in bytes
*
@@ -167,4 +181,14 @@ class User extends Authenticatable
return $this->hasMany(FileManagerFile::class)->withTrashed();
}
/**
* Get user attributes
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function settings() {
return $this->hasOne(UserSettings::class);
}
}