update
This commit is contained in:
@@ -32,6 +32,47 @@ use Session;
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, ValidatesRequests;
|
||||
private function cekBatasAtas($value, $rule) {
|
||||
if (!$rule || !str_contains($rule, '>')) return false;
|
||||
|
||||
$angka = (int) filter_var($rule, FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
return $value > $angka;
|
||||
}
|
||||
private function cekMidRange($value, $rule) {
|
||||
if (!$rule) return false;
|
||||
$rule = trim($rule);
|
||||
|
||||
if ($rule === '-' || $rule === '') return false;
|
||||
|
||||
if (!str_contains($rule, '-')) return false;
|
||||
|
||||
[$min, $max] = array_map('trim', explode('-', $rule));
|
||||
|
||||
if (!is_numeric($min) || !is_numeric($max)) return false;
|
||||
|
||||
return $value >= (int)$min && $value <= (int)$max;
|
||||
}
|
||||
private function cekBatasBawah($value, $rule) {
|
||||
if (!$rule || !str_contains($rule, '<')) return false;
|
||||
|
||||
$angka = (int) filter_var($rule, FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
return $value < $angka;
|
||||
}
|
||||
protected function cekInterpretasi($value, $data) {
|
||||
if ($this->cekBatasAtas($value, $data->batasatas)) {
|
||||
return "S";
|
||||
}
|
||||
if ($this->cekMidRange($value, $data->midrange)) {
|
||||
return "I";
|
||||
}
|
||||
if ($this->cekBatasBawah($value, $data->batasbawah)) {
|
||||
return "R";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getStyledValue($value, $color, $strong = false) {
|
||||
return $strong ? "<strong><font color=\"$color\">$value</font></strong>" : "<font color=\"$color\">$value</font>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user