Eloquent collections return strings instead of double / floating point numbers
EloquentAfter moving a Laravel application from one server to another MySQL issues arise. All of a sudden you get blanks where data from MySQL or Microsoft SQL should be displayed. This worked before on the old server. You troubleshoot using `dd` and then you notice that all numerics are returned as a string. On the old server, `dd` returns actual numerics. The problem is between different operating systems and versions of databases.
The best and quickest workaround is to use casting. Go to your model, then do something similar to this:
class History extends Model { protected $casts = [ 'spread' => 'double', 'bitstamp' => 'double', 'luno' => 'double', 'eurozar' => 'double', 'btcusd' => 'double', ]; } lang-php