Instead of hard coding, store them in a multidimensional array to simplify the manipulation.
$arr = [
["value" => 16, "text" => "2016-2017"],
["value" => 17, "text" => "2017-2018"],
["value" => 18, "text" => "2018-2019"]
...
];
Transfer this data to your views using ViewComposer.
@foreach($arr as $entry)
@if((int) Input::old('year_code') === $entry['value'])
<option value="{{ $entry['value'] }}" selected>{{ $entry['text'] }}</option>
@else
<option value="{{ $entry['value'] }}">{{ $entry['text'] }}</option>
@endif
@endforeach
, , . , . ()
public function getYears(int $diff): array {
$start = Date::today()->startOfYear();
$end = Date::today()->addYears($diff)->startOfYear();
$response = [];
$start->diffInYears($end, function ($year) use (&response) {
$response[] = sprintf("%s - %s", $year->format("Y"), $year->addYear()->format("Y"));
});
return $response;
}