mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 00:22:15 +00:00
subscription detail page
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Users\Models;
|
||||
|
||||
use ByteUnits\Metric;
|
||||
@@ -92,7 +93,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(),
|
||||
@@ -100,20 +101,48 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
}
|
||||
|
||||
return [
|
||||
'used' => (float) get_storage_fill_percentage($this->usedCapacity, $this->limitations->max_storage_amount),
|
||||
'used' => (float)get_storage_fill_percentage($this->usedCapacity, $this->limitations->max_storage_amount),
|
||||
'used_formatted' => get_storage_fill_percentage($this->usedCapacity, $this->limitations->max_storage_amount) . '%',
|
||||
'capacity' => $this->limitations->max_storage_amount,
|
||||
'capacity_formatted' => format_gigabytes($this->limitations->max_storage_amount),
|
||||
];
|
||||
}
|
||||
|
||||
// TODO: caching & refactoring
|
||||
public function accountLimitations(): array
|
||||
{
|
||||
$members = \DB::table('team_folder_members')
|
||||
->where('user_id', $this->id)
|
||||
->pluck('parent_id');
|
||||
|
||||
$membersUse = \DB::table('team_folder_members')
|
||||
->where('user_id', '!=', $this->id)
|
||||
->whereIn('parent_id', $members)
|
||||
->pluck('user_id')
|
||||
->unique()
|
||||
->count();
|
||||
|
||||
return [
|
||||
'max_storage_amount' => [
|
||||
'use' => Metric::bytes($this->usedCapacity)->format(),
|
||||
'total' => format_gigabytes($this->limitations->max_storage_amount),
|
||||
'percentage' => (float)get_storage_fill_percentage($this->usedCapacity, $this->limitations->max_storage_amount),
|
||||
],
|
||||
'max_team_members' => [
|
||||
'use' => $membersUse,
|
||||
'total' => (int)$this->limitations->max_team_members,
|
||||
'percentage' => ($membersUse / $this->limitations->max_team_members) * 100,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user used storage capacity in bytes
|
||||
*/
|
||||
public function getUsedCapacityAttribute(): int
|
||||
{
|
||||
return $this->filesWithTrashed
|
||||
->map(fn ($item) => $item->getRawOriginal())->sum('filesize');
|
||||
->map(fn($item) => $item->getRawOriginal())->sum('filesize');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user