Add File model with getFileSizeInMB; pass sizeInStorage to show-documents

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-06 16:23:16 +05:00
parent fee24d1bce
commit 4d5098a921
3 changed files with 17 additions and 2 deletions

View File

@@ -230,7 +230,8 @@ class AutoController extends Controller
$countDocs = $allFiles->whereIn('type', ['passport_customer', 'certificate', 'appraiser_certificate', 'insurance_policy', 'participate_certificate'])->count(); $countDocs = $allFiles->whereIn('type', ['passport_customer', 'certificate', 'appraiser_certificate', 'insurance_policy', 'participate_certificate'])->count();
$countMediaFiles = $allFiles->whereIn('type', ['object_photo', 'object_files', 'compares'])->count(); $countMediaFiles = $allFiles->whereIn('type', ['object_photo', 'object_files', 'compares'])->count();
$otherFiles = $allFiles->where('type', 'additional')->count(); $otherFiles = $allFiles->where('type', 'additional')->count();
return view('auto.show-documents', compact('order', 'files', 'type', 'countDocs', 'countMediaFiles', 'otherFiles')); $sizeInStorage = $allFiles->sum('size_in_bytes');
return view('auto.show-documents', compact('order', 'files', 'type', 'countDocs', 'countMediaFiles', 'otherFiles', 'sizeInStorage'));
} }
public function orderClone($id) public function orderClone($id)

View File

@@ -212,7 +212,8 @@ class EstateController extends Controller
$countDocs = $allFiles->whereIn('type', ['passport_customer', 'certificate', 'appraiser_certificate', 'insurance_policy', 'participate_certificate'])->count(); $countDocs = $allFiles->whereIn('type', ['passport_customer', 'certificate', 'appraiser_certificate', 'insurance_policy', 'participate_certificate'])->count();
$countMediaFiles = $allFiles->whereIn('type', ['object_photo', 'object_files', 'compares'])->count(); $countMediaFiles = $allFiles->whereIn('type', ['object_photo', 'object_files', 'compares'])->count();
$otherFiles = $allFiles->where('type', 'additional')->count(); $otherFiles = $allFiles->where('type', 'additional')->count();
return view('estate.show-documents', compact('order', 'files', 'type', 'countDocs', 'countMediaFiles', 'otherFiles')); $sizeInStorage = $allFiles->sum('size_in_bytes');
return view('estate.show-documents', compact('order', 'files', 'type', 'countDocs', 'countMediaFiles', 'otherFiles', 'sizeInStorage'));
} }
public function orderClone($id) public function orderClone($id)

13
app/Models/File.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
namespace App\Models;
class File
{
public static function getFileSizeInMB(int $bytes): string
{
if ($bytes <= 0) return '0';
$mb = $bytes / 1024 / 1024;
return number_format($mb, 2);
}
}