Q:

Laravel Eloquent query building for serching by year of a date

I am a beginner at laravel and I am working in implementing a search. 
there is a row of date and I need to search by year, I read and tried a couple of solutions but I could not find a good solution. 
this is the query i found in internet as a potential solution but this is not working:
$Data = DB::table('actuals')->where('company_id',$companyId)->whereYear('date', '=', $SearchInput)->orderBy('date', 'asc')->get();

A:

This should work for you:
$Data = DB::table('actuals')->where(function($nest) use($SearchInput,$companyId) {
    $nest->where('company_id',$companyId);
    $nest->whereYear('date', '=', $SearchInput); 
})->orderBy('date', 'asc')->get();

