I've a weird problem. On my production machine, when I view the data types of my variables in my models, it seems they are getting changed from integer (as set in mysql) and converting them the strings. I'm finding I'm having to add mutators to the models to force them back to the correct type.
(Obviously) on my local dev environment, using an exact copy of the database, nothing is changing the types.
That's much cleaner than the mutators I've been adding.
I've been having a look around stack overflow and it seems that the sql drivers on windows and mac do pass the values through with the correct type, which explains the inconsistency with the production machine.
There is a fix for this with involves swapping the driver to a different one so I'll have fiddle with that as there are a lot of variables I'd have to cast on this project if not :(
I've just fixed this very same issue by upgrading the mysql driver php was using...
sudo apt-get install php5-mysqlnd
This means it uses PDO drivers rather than the old mysql/mysqli drivers. It removes the old ones and replaces them with it's own.
This appears to fix this issue without the need to use $casts. Though for belt and braces, it won't hurt to use $casts as well if you've already changed your models.
@billythekid I have my production server on DigitalOcean (installed via Laravel Forge) and I think that I have the "php5-mysqld" installed on that server.
To change that driver to "php5-mysqlnd" I only have to execute:
sudo apt-get install php5-mysqlnd
One the shell? I have to uninstall the other driver first or configure anything later?