Alejandro
Alejandro
FFilament
Created by Alejandro on 1/17/2024 in #❓┊help
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?
2 replies
FFilament
Created by Alejandro on 7/30/2023 in #❓┊help
How to use hidden() in a table programmatically
I need to hide a column if another column doesn't have a given value. But this doesn't work on any way.
Tables\Columns\SelectColumn::make('rate')
->options([
'1' => '1 star',
'2' => '2 stars',
'3' => '3 stars',
'4' => '4 stars',
'5' => '5 stars',
])
->hidden(function(Closure $get) {
return $get('status') !== 'approved';
})
->label('Calificación'),
Tables\Columns\SelectColumn::make('rate')
->options([
'1' => '1 star',
'2' => '2 stars',
'3' => '3 stars',
'4' => '4 stars',
'5' => '5 stars',
])
->hidden(function(Closure $get) {
return $get('status') !== 'approved';
})
->label('Calificación'),
5 replies