Arif Hossain
Bulk action to Get Selected Material and Create New Order With These Materials
1. pass the records ids as coma separated in redirect
$data['item_ids'] = $records
->pluck('id')
->implode(',');
return redirect()->route('filament.app.resources.orders.create', $data);
2. in the CreateOrder resource page, overwrite method fillForm
as like below
protected function fillForm(): void
{
$itemIds = collect (request('item_ids'))->explode(',')->toArray();
// for filling repeater field 'items'
$data['items'] = collect(request('item_ids'))
->explode(',')
->map(
function ($itemId) {
$item = ''; // format/load/prepare item with itemId
return [
"material_id" => $item->material_id,
"qty" => $item->qnt,
"unit_price" => $item->unit_price
];
}
)->toArray()
$this->callHook('beforeFill');
$this->form->fill($data);
$this->callHook('afterFill');
}
5 replies