fill($request->input()); if($request->input('invoices')) { $invoices = Invoice::whereIn('id', $request->input('invoices'))->get(); } //parse invoices[] and attach to paymentables //parse invoices[] and apply payments and subfunctions $payment->save(); return $payment; } }