Whats the right way to store JSON in a database with Laravel? -


i have json data want store in database. ideally, data should automatically decoded when retreive database , automatically encoded when store in database.

how can this?

use accessors , mutators, attribute called foobar add these 2 functions in eloquent model:

public function getfoobarattribute($value){     return json_decode($value); } public function setfoobarattribute($value){     $this->attributes['foobar'] = json_encode($value); } 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -