return value - Laravel 5.2 can't read model property type from DB like as 'number' (with PHP7) -


i've weird problem local environment.

if return laravel model json, every attributes returned string , not numbers or booleans.

$j = jobposition::find($id); return $j; 

if use php 5.5 return-types correct.

on server works fine php7, think it's local php setup.

here is, how compiled php 7.0.4:

./buildconf --force env yacc=`brew --prefix bison27`/bin/bison ./configure  --prefix="/usr/local/opt/phpng"  --with-config-file-path="/usr/local/etc/phpng"  --enable-bcmath  --enable-calendar  --enable-exif  --enable-ftp  --enable-gd-native-ttf  --enable-gd-jis-conv  --enable-mbstring  --enable-pcntl  --enable-sysvmsg  --enable-sysvsem  --enable-sysvshm  --enable-wddx  --enable-zip  --enable-json  --with-bz2  --with-curl  --with-iconv  --with-freetype-dir=`brew --prefix freetype`  --with-gd  --with-gettext=`brew --prefix gettext`  --with-gmp  --with-jpeg-dir=`brew --prefix gd`  --with-mcrypt=`brew --prefix mcrypt`  --with-mysqli=`brew --prefix`/bin/mysql_config  --with-openssl  --with-pdo-mysql=`brew --prefix mariadb`  --with-png-dir=`brew --prefix gd`  --with-zlib=`brew --prefix zlib`  make -j`sysctl -n hw.logicalcpu_max`  env install_root=$pwd/phpng-pkg make install  pkgbuild  --root phpng-pkg  --identifier net.php.phpng  --version 7.0.4-dev  --ownership recommended  phpng-dev.pkg 

according following tutorial: http://www.justinsilver.com/technology/install-php-7-0-phpng-on-mac-os-x/

my findings: encoding working correctly - json_encode looks fine.

a workaround use $casts attribute in model. why defining it, if should work out of box (and wanna know problem ;-) )

thanks stefan

update 29.02.2016: stupid, haven't checked first. problem has nothing json! model filled false , incorrect.

app\job\company\jobposition {#994      id: "1",      title: "maxime natus.",      salary: "3181",      contact: "aglae.shanahan@yahoo.com",      published: "1",      approved: "1", } 

it occured me (about year ago), models types not returned adequately when switched dev server @ workplace.

the reason had installed mysqlnd (php package) on local vm, helps php determine proper variable type result set.

without that, it's totally fine have every type returned string.

i saw configure call includes mysqli driver definitions. might suffice not define it's default since 5.4 (that's @ least docs http://php.net/manual/de/mysqlnd.install.php)

this of course fits, if we're talking mysql database.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -