In MySQL, I can use the YEAR() function to filter by year the date field in the WHERE
SELECT noworkorder FROM workorders WHERE YEAR(date)=2015;
In Laravel, of course, I can achieve the same as raw expression :
$data = DB::table('workorders') ->select('noworkorder') ->where(DB::raw('YEAR(date)=2015')) ->orderby('noworkorder', 'desc') ->get();
But is there a way to do this without raw expressions?
source share