where('agent_node_id', $agent->id)->first(); if ($profile === null) { return; } $limit = (float) $profile->rebate_limit; if ($rebateRate > $limit) { throw ValidationException::withMessages([ 'rebate_rate' => ['exceeds_limit'], ]); } if ($extraRebateRate > 0 && ! $profile->can_grant_extra_rebate) { throw ValidationException::withMessages([ 'extra_rebate_rate' => ['not_allowed'], ]); } } }