Have a next blade code, where are 2 years "from" and "to". This is the annual range of films to be retrieved from the films table. Films from this year to this year.
<div class="year-wrapper">
<div class="year-input">
<div class="year-field">
<span>year from</span>
<input type="number" class="year-input-min" value="{{ $yearMin }}" name="year">
</div>
<div class="year-separator">-</div>
<div class="year-field">
<span>year to</span>
<input type="number" class="year-input-max" value="{{ $yearMax }}" name="year">
</div>
</div>
<div class="year-slider">
<div class="year-progress"></div>
</div>
<div class="year-range-input">
<input type="range" class="range-min" min="{{ $yearMin }}" max="{{ $yearMax - 1 }}" value="{{ $yearMin }}" step="1">
<input type="range" class="range-max" min="{{ $yearMin + 1 }}" max="{{ $yearMax }}" value="{{ $yearMax }}" step="1">
</div>
</div>
It looks like a range slider with two inputs "year from" and "year to"
And also have a filtering construction in Builder, which search films by year. Seems like below:
<?php
namespace App\Models\Filters\Film;
use App\Services\Filters\Filterable;
use Illuminate\Database\Eloquent\Builder;
use App\Models\Film;
class Year implements Filterable
{
public static function apply(Builder $builder, $value)
{
$builder->whereBetween('year', [1944, 1954]);
return $builder;
}
}
The problem is that I don't know how to replace the example-years 1944 and 1954 with variables that would intercept the values from the first and second input, respectively. None of my attempts and googling helped.
Can you tell me how to substitute variables in Builder instead of these numbers?