where('owner_type', 'agent') ->where('owner_id', $agentNodeId) ->where('status', 'overdue') ->where('unpaid_amount', '>', 0) ->exists(); } public static function assertAgentMayGrantCredit(int $agentNodeId): void { if (self::agentHasOverdueBills($agentNodeId)) { throw \Illuminate\Validation\ValidationException::withMessages([ 'credit' => ['agent_overdue'], ]); } } }