I want to filter the year in my varchar column named schedule
using laravel whereYear()
. However it returns an error shown in the image below. One more thing is that, I am not pointing the whereYear
to created_at
date column in the database that everyone is using. Below is my code. Please help. Thanks.
Controller:
$year = $request['bill_year'];
$month = $request['bill_month'];
$period = $request['bill_period'];
if( is_numeric($year) ){
$amortizations = Amortization::whereYear('schedule', $year)->where('bill_status',0)->get();
if($amortizations){
$notification = "Success";
} else{
$notification = "Failed";
}
return json_encode(array('notify'=>$notification, 'amortizations' => $amortizations, 'year' => $year, 'month' => $month, 'period' => $period));
}
Column 'schedule'
in the database
error: