F
Filamentβ€’17mo ago
yeonjih

update data in other tables

Please guide me for updating other tables without using repeater . Ex. I want to update automatically the quantity of items after submitting the invoice in invoiceresource.
6 Replies
yeonjih
yeonjihOPβ€’17mo ago
->actions([ Tables\Actions\Action::make('Qty') ->name('Quantity') // ->iconButton() ->form([Forms\Components\TextInput::make('udpate_qty') ->name('') ->numeric() ]) // ->action(function (array $data): void{ // Item::updated([$data]); // }) ->action(function ($get, $state) { DB::table('items') ->where('item_code',$get('item_code')) ->update(['item_qty'=> $get('item_qty')+ $state]); }) ->modalWidth('sm') is this ok to use ?
Patrick Boivin
Patrick Boivinβ€’17mo ago
Hi @yeonjih, check tip # 4 here on how to format your code: https://discord.com/channels/883083792112300104/883264995603935272/983367389905305611 Do you have any issues with this? Is the code doing what you want?
LeandroFerreira
LeandroFerreiraβ€’17mo ago
->action(function($record) {
//...
})
->action(function($record) {
//...
})
yeonjih
yeonjihOPβ€’17mo ago
I will try later. Thank you for response Hello, my problem now is how to fetch from input text. I got an error if I use fn($get)=>get('field_name') ->actions([ Tables\Actions\Action::make('Qty')

->name('Quantity') // ->iconButton() ->form([Forms\Components\TextInput::make('update_qty') ->name('') ->numeric() ->required() ]) ->action(function($record){ Item::where('id',$record->id) ->update([ "item_qty" => //I need to post here ]); }) @pboivin Hello regarding this matter πŸ™‚ thank you
Saade
Saadeβ€’17mo ago
->action(function(Item $record, array $data){
$record->update([
"item_qty" => $data['update_qty'],
]);
})
->action(function(Item $record, array $data){
$record->update([
"item_qty" => $data['update_qty'],
]);
})
yeonjih
yeonjihOPβ€’17mo ago
Thank you. It works
Want results from more Discord servers?
Add your server