I created a Form macro for this, basically extending the existing selectRange macro:
class FormBuilder extends FB
{
public function selectRangeWithInterval($name, $start, $end, $interval, $default = null, $attributes = [])
{
if ($interval == 0) {
return $this->selectRange($name, $start, $end, $default, $attributes);
}
$items = [];
$startValue = $start;
$endValue = $end;
if ($interval < 0) {
$interval *= -1;
}
if ($start > $end) {
if ($interval > 0) {
$interval *= -1;
}
$startValue = $end;
$endValue = $start;
}
for ($i=$startValue; $i<$endValue; $i+=$interval) {
$items[$i . ""] = $i;
}
$items[$endValue] = $endValue;
if (!in_array($default, $items)) {
$items[$default] = $default;
}
return $this->select($name, $items, $default, $attributes);
}
}
This can then be used in your view something like this:
{{ Form::selectRangeWithInterval('weightOfSackOfFeathers', 0, 7500, 150, null, ['class' => 'form-control input-xs']) }}