components([ TextInput::make('title') ->required() ->live(onBlur: true) ->afterStateUpdated(function ($state, $set): void { $set('slug', Str::slug((string) $state)); }), TextInput::make('slug') ->required() ->dehydrated() ->readOnly(), Textarea::make('description') ->columnSpanFull(), SpatieMediaLibraryFileUpload::make('featured_image') ->collection('featured-image') ->image() ->imageEditor() ->columnSpanFull(), Toggle::make('is_published') ->required(), Toggle::make('is_featured') ->required(), DatePicker::make('published_at'), RichEditor::make('content') ->columnSpanFull() ->hintAction( Action::make('picker') ->label('Gallery Picker') ->icon('heroicon-m-photo') ->schema([ Select::make('image_url') ->label('Select an existing image') ->allowHtml() ->options(function () { // We must 'get' the collection first so we can call getUrl() // because 'url' is not a column in the Spatie database table. return Media::latest() ->get() ->mapWithKeys(function (Media $item) { $url = $item->getUrl(); $fileName = e($item->file_name); $name = e($item->name ?? ''); $html = "