add time_added field to FilesBlock; update file upload logic to set timestamp and improve file display in FileBlock with additional metadata

This commit is contained in:
F4ilji
2025-07-25 12:36:17 +05:00
parent e403203e72
commit 16e7b9fe46
10 changed files with 211 additions and 66 deletions
@@ -24,6 +24,7 @@ class FilesBlock implements BlockSchema
->schema([
Hidden::make('expansion')->required(),
Hidden::make('size')->required(),
Hidden::make('time_added')->required(),
TextInput::make('title')
->label('Название файла')
->placeholder('Введите название файла')
@@ -51,8 +52,10 @@ class FilesBlock implements BlockSchema
->directory('files')
->downloadable()
->afterStateUpdated(function ($set, $state) {
$set('title', $state?->getClientOriginalName());
$set('expansion', $state?->getClientOriginalExtension());
$set('size', ByteConverter::bytesToHuman($state?->getSize()));
$set('time_added', Carbon::now()->timestamp);
})
->visibility('public')
->preserveFilenames()
@@ -63,4 +66,4 @@ class FilesBlock implements BlockSchema
->grid(2),
];
}
}
}
@@ -28,13 +28,11 @@ class PersonBlock implements BlockSchema
FileUpload::make('photo')
->label('Фотография')
->image()
->helperText('Рекомендуемый формат: WebP')
->optimize('webp')
->resize(50)
->disk('public')
->directory('images')
->imageEditor()
->required()
->downloadable()
->openable(),
Repeater::make('info')
@@ -60,4 +58,4 @@ class PersonBlock implements BlockSchema
->itemLabel(fn (array $state): ?string => $state['column'] ?? null),
];
}
}
}