The custom validation rule is :
Validator::extend('greater_than', function($attribute, $value, $parameters) {
if (isset($parameters[0])) {
return intval($value) > intval($parameter[0]);
} else {
return false;
}
}
max_occupancy rule would then be:
'max_occupancy' => 'required|integer|max:100|greater_than:base_occupancy'
but the "$parameters" array returning is : array:1 [▼ 0 => "base_occupancy"]. so i am not getting the value of base_occupancy to check "greater_than" condition.
Use
$validator->getData()
. It will return a key-value array that has the key are form input names and the value are their values.In your case, fix like this: