How can I do a type cast for comparing values in Laravel Fluent? For example if I have the following MySQL:
SELECT * from table1 WHERE CAST(`values` AS SIGNED) > $myVar
This is what I currently have after writing the above in Fluent:
$query = DB::connection('mysql')->table('table1')
->where('values', '>', $myVar);
Currently the database is treating this as a string. The column in the table needs to be kept as a varchar for other reasons. How can I do the type cast for this particular query in Laravel Fluent?
Untested, but I believe this should work:
$query = DB::connection('mysql')->table('table1')
->where(DB::raw('CAST(values AS SIGNED)'), '>', $myVar);