$result['tests'] = Test::select('test.test_id',
DB::raw('convert_tz(test.updated_at,+00:00,-05:30) as updated_at'),
'test.created_at')
->orderBy('test.test_id', 'ASC')
->get()->toArray();
我已经找到了CASE WHEN查询的解决方案,例如 DB::raw('(CASE WHEN favorite.is_favorite IS NULL THEN 0 ELSE favorite.is_favorite END) AS is_favorite'),
但问题是我不能对值在引号内的CONVERT_TZ做同样的事情。
DB::raw('convert_tz(test.updated_at,+00:00,-05:30) as updated_at')