Realizo esta consulta:
public static function searchYear($year)
{
return DB:: table('contract_works')
->select(DB::raw('Year(dateFailure) as dt'))
->where('dt',$year)
->orderBy('dt','asc')
->get();
}
pero me dice que el campo no existe, obteniendo este error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dt' in 'where clause' (SQL: select Year(dateFailure) as dt from
contract_works
wheredt
= 1970 order bydt
asc)