orderBy('max_perf', 'desc')->get(); $rebateRatio = 0; foreach ($ruleData as $val) { if ($perfTotal > $val['min_perf'] && $perfTotal <= $val['max_perf']) { $rebateRatio = $val['rebate_ratio']; } } return $rebateRatio * 100; } }