如何通过使用laravel中的哪个来搜索年龄范围?

I am trying to filter the age like 15 to 30 years old or something like that.Here is how i tried to,

<div class="form-group col-md-4">
<input type="text" name="first_age" placeholder="From">
</div>
<div class="form-group col-md-4">
<input type="text" name="second_age" placeholder="To">
</div>

And in my MyModel.php

public function scopeSearch($query, $request)
{   if ($request->first_age!='') {       
    $query->whereBetween('age', [$request->first_age, $request->first_age]);

  }
     return $query->select('jobseekers.*');   
}

Can anyone guide me where am i wrong? Thanks in advance.

You are calling first_age twice in your whereBetween.

$query->whereBetween('age', [$request->first_age, $request->second_age]);