validCreditsPresent(); } /** * @return string */ public function message() { return 'Attempting to use one or more invalid credits'; } private function validCreditsPresent() :bool { //todo need to ensure the clients credits are here not random ones! if(request()->input('credits') && is_array(request()->input('credits'))) { foreach(request()->input('credits') as $credit) { $cred = Credit::find($credit['invoice_id']); if($cred->balance >= $credit['amount']) return false; } } return true; } }