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
yeonjihOP2y 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
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
->action(function($record) {
//...
})
->action(function($record) {
//...
})
yeonjih
yeonjihOP2y 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
Saade2y 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
yeonjihOP2y ago
Thank you. It works

Did you find this page helpful?