Folder tree dynamic navigator

This commit is contained in:
Čarodej
2022-01-21 16:46:17 +01:00
parent 6cb2a1bb9a
commit e2cfdd5345
11 changed files with 68 additions and 1332 deletions
-13
View File
@@ -121,19 +121,6 @@ class User extends Authenticatable implements MustVerifyEmail
->sum('filesize');
}
/**
* Get user full folder tree
*/
public function getFolderTreeAttribute(): Collection
{
return Folder::with(['folders.shared', 'shared:token,id,item_id,permission,is_protected,expire_in'])
->where('parent_id')
->where('team_folder', false)
->where('user_id', $this->id)
->sortable()
->get();
}
public function settings(): HasOne
{
return $this->hasOne(UserSetting::class);
-1
View File
@@ -36,7 +36,6 @@ class UserResource extends JsonResource
'role' => $this->role,
'two_factor_authentication' => $this->two_factor_secret ? true : false,
'socialite_account' => $this->password ? false : true,
'folders' => $this->folder_tree,
'storage' => $this->storage,
'created_at' => format_date($this->created_at, '%d. %b. %Y'),
'updated_at' => format_date($this->updated_at, '%d. %B. %Y'),
@@ -134,13 +134,13 @@ class UserStorageResource extends JsonResource
->get();
$upload = $trafficRecords->map(fn($record) => [
'created_at' => format_date($record->created_at),
'created_at' => format_date($record->created_at, '%d. %B'),
'percentage' => $uploadMax !== 0 ? round(($record->upload / $uploadMax) * 100, 2) : 0,
'amount' => Metric::bytes($record->upload)->format(),
]);
$download = $trafficRecords->map(fn($record) => [
'created_at' => format_date($record->created_at),
'created_at' => format_date($record->created_at, '%d. %B'),
'percentage' => $downloadMax !== 0 ? round(($record->download / $downloadMax) * 100, 2) : 0,
'amount' => Metric::bytes($record->download)->format(),
]);