SpatieMediaLibraryFileUpload inside a Repeater

Hello, I have a model pages, model pages have a json column that I call cf. Each page has a different form template, all form values are saved in json format in the cf column. So far ok, everything works wonderfully, creation, editing, etc. I want to place a SpatieMediaLibraryFileUpload inside a repeater. I know that SpatieMediaLibraryFileUpload has multiple(), but I wanted some additional inputs for each image, so it is inside a repeater. My difficulty is the combination of spatie media with repeater. It even saves cool, when opening the edit it takes only 1 of the images and places the same one in all the repetitions, ignoring the other images uploaded previously. This makes sense, since make("name") is the same in all of them. I've been trying to make this work for 5 days, I've tried some types of mixin and some Closures but I'm already wanting to cry in the fetal position. Does anyone have a smarter (or less stupid) idea?
Tabs\Tab::make('Marcas')
->hidden(fn (?Model $record) => $record?->layout !== 'cases')
->schema([
Repeater::make('cf.marcas')->schema([
self::image(name:'cf.marca.image', label: "Imagem"),
TextInput::make('cf.marca.nome'),
TextInput::make('cf.marca.link')->url(),
])->columnSpan('full')->grid(2),
])
Tabs\Tab::make('Marcas')
->hidden(fn (?Model $record) => $record?->layout !== 'cases')
->schema([
Repeater::make('cf.marcas')->schema([
self::image(name:'cf.marca.image', label: "Imagem"),
TextInput::make('cf.marca.nome'),
TextInput::make('cf.marca.link')->url(),
])->columnSpan('full')->grid(2),
])
public static function image($name, $label = null): Field
{
return
SpatieMediaLibraryFileUpload::make($name)
->label($label)
->collection($name)
->disk('public')
->deletable()
->optimize('webp');
}
public static function image($name, $label = null): Field
{
return
SpatieMediaLibraryFileUpload::make($name)
->label($label)
->collection($name)
->disk('public')
->deletable()
->optimize('webp');
}
One thing I thought might work is the solution from this link https://github.com/filamentphp/filament/pull/10795, but the whereCustomProperties function seems to have ceased to exist, I'm up to date and it doesn't exist
0 Replies
No replies yetBe the first to reply to this messageJoin