getFormDataMutation($data); } public function getFormDataMutation(array $data): array { return Arr::except($data, ['client', 'transactions']); } protected function afterCreate(): void { $transactions = Arr::only($this->form->getState(), ['transactions']); try { $branch = $this->getRecord()->branch; foreach ($transactions as $transaction) { $data = [ 'branch_id' => $branch->id, 'happened_on' => $this->getRecord()->happened_on, ...Arr::first($transaction), ]; $payload = new CreateTransactionDTO(data: $data, transactionable: $this->getRecord()); Pipeline::send(passable: $payload)->through( [ CreateTransactionAction::class, ] )->thenReturn(); } $this->commitDatabaseTransaction(); } catch (Exception $exception) { $this->rollBackDatabaseTransaction(); throw new LogicException('Failed to save transactions : '.$exception->getMessage()); } } }