label('Файлы') ->helperText('Загрузите один или несколько файлов') ->schema([ Hidden::make('expansion')->required(), Hidden::make('size')->required(), Hidden::make('time_added')->required(), TextInput::make('title') ->label('Название файла') ->placeholder('Введите название файла') ->required() ->maxLength(255) ->autofocus() ->helperText('Это название будет отображаться пользователям'), FileUpload::make('path') ->label('Файл') ->required() ->helperText('Поддерживаются PDF, Word, Excel, PowerPoint и ZIP файлы') ->getUploadedFileNameForStorageUsing( fn (TemporaryUploadedFile $file): string => str(Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME) . '-' . Carbon::now()->timestamp) . '.' . $file->getClientOriginalExtension()) ) ->acceptedFileTypes([ 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/zip' ]) ->maxSize(512000) ->disk('public') ->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() ]) ->itemLabel(fn (array $state): ?string => $state['title'] ?? null) ->collapsible() ->cloneable() ->grid(2), ]; } }