components([ Select::make('module_id') ->relationship('module', 'title') ->required(), TextInput::make('title') ->required(), TextInput::make('slug') ->required(), TextInput::make('type') ->required() ->default('text'), Textarea::make('content') ->columnSpanFull(), TextInput::make('video_url') ->url() ->placeholder('https://youtube.com/watch?v=...') ->visible(fn (callable $get) => $get('type') === 'video'), \Filament\Forms\Components\SpatieMediaLibraryFileUpload::make('content_pdf') ->collection('content_pdf') ->disk('r2') ->visibility('public') ->acceptedFileTypes(['application/pdf']) ->label('Upload PDF Material') ->visible(fn (callable $get) => $get('type') === 'pdf'), // Legacy URL input if needed, or remove. Keeping it hidden if empty? // Let's keep it as an alternative or just replace it. // Assuming we want to fully switch to upload: // TextInput::make('content_pdf')->label('PDF URL (Legacy)'), TextInput::make('duration_seconds') ->required() ->numeric() ->default(0) ->suffix('Seconds'), \Filament\Forms\Components\SpatieMediaLibraryFileUpload::make('attachments') ->collection('attachments') ->disk('r2') ->visibility('public') ->multiple() ->downloadable() ->label('Attachments (Downloadable Resources)'), Toggle::make('is_free_preview') ->required(), TextInput::make('order_index') ->required() ->numeric() ->default(0), Textarea::make('metadata') ->columnSpanFull() ->rows(5), Select::make('vocabularies') ->relationship('vocabularies', 'word') ->multiple() ->searchable() ->preload() ->label('Focus Vocabularies'), ]); } }