payment = $payment; } public function manualPayment($invoice) :?Payment { /* Create Payment */ $payment = PaymentFactory::create($invoice->company_id, $invoice->user_id); $payment->amount = $invoice->balance; $payment->status_id = Payment::STATUS_COMPLETED; $payment->client_id = $invoice->client_id; $payment->transaction_reference = ctrans('texts.manual_entry'); /* Create a payment relationship to the invoice entity */ $payment->save(); $payment->invoices()->attach($invoice->id, [ 'amount' => $payment->amount ]); return $payment; } }