Update BackupResource.php

This commit is contained in:
Bozhidar 2024-05-09 15:20:03 +03:00
parent 969cd8c376
commit 828d650d6d

View file

@ -7,6 +7,7 @@ use App\Filament\Enums\BackupStatus;
use App\Filament\Enums\BackupType;
use App\Filament\Resources\BackupResource\Pages;
use app\Filament\Resources\BackupResource\Widgets\BackupStats;
use App\Helpers;
use App\Models\Backup;
use App\Models\HostingSubscription;
use Filament\Forms\Components\Select;
@ -83,17 +84,17 @@ class BackupResource extends Resource
return $backup->created_at ? $backup->created_at : 'N/A';
}),
Tables\Columns\TextColumn::make('completed_at')
->label('Completed time')
->state(function (Backup $backup) {
$diff = \Carbon\Carbon::parse($backup->completed_at)
->diffForHumans($backup->created_at);
return $backup->completed_at ? $diff : 'N/A';
}),
// Tables\Columns\TextColumn::make('completed_at')
// ->label('Completed time')
// ->state(function (Backup $backup) {
// $diff = \Carbon\Carbon::parse($backup->completed_at)
// ->diffForHumans($backup->created_at);
// return $backup->completed_at ? $diff : 'N/A';
// }),
Tables\Columns\TextColumn::make('size')
->state(function (Backup $backup) {
return $backup->size ? $backup->size : 'N/A';
return ($backup->size > 0) ? Helpers::getHumanReadableSize($backup->size) : 'N/A';
}),
])
->filters([