inventoryAccounts=InventoryAccount::query()->get(); } public function testUpdateInventoryAccount(){ $updateParams = [[ 'id','processed','ignored','updated_at' ]]; $updated_at=Carbon::now()->toDateTimeString(); foreach ($this->inventoryAccounts as $inventoryAccount){ if ($inventoryAccount->getIgnoredAmount()>0){ $updateParams[] = [ 'id'=>$inventoryAccount->id, 'processed'=>$inventoryAccount->getProcessedAmount(), 'ignored' => $inventoryAccount->getIgnoredAmount(), 'updated_at'=>$updated_at, ]; } } if(count($updateParams) > 1){ $this->batchUpdate($updateParams); } } public function batchUpdate($params){ return app(BatchUpdateService::class)->batchUpdate('inventory_accounts',$params); } }