Problem using $record on FileUpload directrory inside a repeater

I have a repeater with a relationship, and I want images to be uploaded inside a directory, using the main record ID to define the directory:
Tabs\Tab::make('Images')
->hidden(fn($record) => !$record)
->icon('heroicon-o-photo')
->schema([
Forms\Components\Repeater::make('images')
->relationship()
->minItems(0)
->defaultItems(0)
->orderColumn('sort')
->columnSpan(2)
->schema([
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\FileUpload::make('file')
->directory(function ($record) {
Log::info($record);
return "quotes/{$record->id}";
})
->image()
->imageEditor()
->imageResizeMode('contain')
->imageResizeTargetWidth(2048)
->imageResizeTargetHeight(2048)
->imageResizeUpscale(false)
->maxSize(4096)
]),
]),
Tabs\Tab::make('Images')
->hidden(fn($record) => !$record)
->icon('heroicon-o-photo')
->schema([
Forms\Components\Repeater::make('images')
->relationship()
->minItems(0)
->defaultItems(0)
->orderColumn('sort')
->columnSpan(2)
->schema([
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\FileUpload::make('file')
->directory(function ($record) {
Log::info($record);
return "quotes/{$record->id}";
})
->image()
->imageEditor()
->imageResizeMode('contain')
->imageResizeTargetWidth(2048)
->imageResizeTargetHeight(2048)
->imageResizeUpscale(false)
->maxSize(4096)
]),
]),
But $record is always null, what am I doing wrong?
1 Reply
Paulo Cavalcanti
Same here. On create, the record do not exist, but in edit it should be available (in theory)
Want results from more Discord servers?
Add your server