Level 2
Jan 21, 2024
3
Level 2
Filament Repeater Data are not posting
when i
dd($data);
is not showing the repeater data in
protected function handleRecordCreation(array $data)
I could not find the issue
The Repeater
Repeater::make('items')
->label(__('Request Tools and Equipments'))
->relationship()
->schema([
Forms\Components\Select::make('category_id')
->options(AssetsCategory::all()->pluck('name', 'id')->toArray())
->reactive()
->afterStateUpdated(fn (callable $set) => $set('tool_id', null)),
Forms\Components\Select::make('tool_id')
->options(function (callable $get){
$category = AssetsCategory::find($get('category_id'));
if(!$category){
return AssetsTools::all()->pluck('name', 'id');
}
return $category->tools->pluck('name', 'id');
})->reactive()
->afterStateUpdated(fn (callable $set) => $set('subTool_id', null)),
Forms\Components\Select::make('subTool_id')
->options(function (callable $get){
$tool = AssetsTools::find($get('tool_id'));
if(!$tool){
return subTools::all()->pluck('size', 'id');
}
return $tool->subTools->pluck('size', 'id');
})->reactive(),
Forms\Components\TextInput::make('quantity')
->required()
->numeric()
->minValue(1)
->maxValue(function (Callable $get){
$sub_tool = SubTools::find($get('tool_id'));
if(empty($sub_tool)){
return 1;
}
return $sub_tool->quantity;
}),
])->addActionLabel('Add Items')
->columns(4)
->columnSpanFull()
->cloneable(),
This is the relation
public function items(): HasMany
{
return $this->hasMany(ToolsRequestItems::class, 'request_id');
}
Please or to participate in this conversation.