How to use mySQL convert_tz functions in Laravel/Lumen query builder

1.4k Views Asked by At
$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();

I already find the solution for CASE WHEN queries like DB::raw('(CASE WHEN favorite.is_favorite IS NULL THEN 0 ELSE favorite.is_favorite END) AS is_favorite'),

But the problem is I cannot do the same with CONVERT_TZ where the values are inside the quotes.

DB::raw('convert_tz(test.updated_at,+00:00,-05:30) as updated_at')

0

There are 0 best solutions below