mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
api resource refactoring part 3
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Users\Models;
|
||||
|
||||
use ByteUnits\Metric;
|
||||
@@ -95,7 +96,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
$is_storage_limit = get_settings('storage_limitation') ?? 1;
|
||||
|
||||
if (! $is_storage_limit) {
|
||||
if (!$is_storage_limit) {
|
||||
return [
|
||||
'used' => $this->usedCapacity,
|
||||
'used_formatted' => Metric::bytes($this->usedCapacity)->format(),
|
||||
@@ -103,7 +104,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
}
|
||||
|
||||
return [
|
||||
'used' => (float) get_storage_fill_percentage($this->usedCapacity, $this->settings->storage_capacity),
|
||||
'used' => (float)get_storage_fill_percentage($this->usedCapacity, $this->settings->storage_capacity),
|
||||
'used_formatted' => get_storage_fill_percentage($this->usedCapacity, $this->settings->storage_capacity) . '%',
|
||||
'capacity' => $this->settings->storage_capacity,
|
||||
'capacity_formatted' => format_gigabytes($this->settings->storage_capacity),
|
||||
@@ -116,7 +117,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
public function getUsedCapacityAttribute(): int
|
||||
{
|
||||
return $this->filesWithTrashed
|
||||
->map(fn ($item) => $item->getRawOriginal())->sum('filesize');
|
||||
->map(fn($item) => $item->getRawOriginal())->sum('filesize');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +166,10 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
public function latestUploads(): HasMany
|
||||
{
|
||||
return $this->hasMany(File::class)
|
||||
->with(['parent:id,name'])
|
||||
->with([
|
||||
'parent:id,name',
|
||||
'shared:token,id,item_id,permission,is_protected,expire_in',
|
||||
])
|
||||
->take(40);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user