fill($data); $expense->save(); if (array_key_exists('documents', $data)) { $this->saveDocuments($data['documents'], $expense); } // if ($expense->id_number == "" || !$expense->id_number) { // $expense->id_number = $this->getNextExpenseNumber($expense); // } //todo write tests for this and make sure that custom expense numbers also works as expected from here return $expense; } /** * Store expenses in bulk. * * @param array $expense * @return expense|null */ public function create($expense): ?Expense { return $this->save( $expense, ExpenseFactory::create(auth()->user()->company()->id, auth()->user()->id) ); } }