I am making a simple query request with a where condition. I need to have in this condition the year of a date field, in SQL i use "YEAR(date)=2015" In laravel when i use it, i get an error because he didnt find the column.
$total_num_rows_y = DB::table('insatisfaction')
->select(DB::raw('COUNT(id) as total_num_rows_y'))
->where('foo', $foo->id_aj)
->where('YEAR(date)', '2015')
->get();
Could you help me?
Let's try :
$total_num_rows_y = DB::table('insatisfaction')
->select(DB::raw('COUNT(id) as total_num_rows_y'))
->where('foo', $foo->id_aj)
->where(DB::raw('YEAR(start)'), '=', date('Y'));
->get();