Laravel 4 - decoding json into view
Use an Eloquent Accessor to transform your data as you need it.
/** * Eloquent accessor to transform our content_data column * from JSON to an array. * * @param string $data Original JSON data * @return array */public function getContentDataAttribute($data){ return json_decode($data);}
You can then retrieve your column via $content->content_data
as usual, but it will be converted into an array.
You can do the inverse when saving data to that column by transforming the passed array into a JSON encoded string, also, using a mutator.