// To set the value
public function setDataAttribute($value){
$this->attributes['data'] = json_encode($value);
}
// To get the value
public function setDataAttribute($value){
return json_decode($this->attributes['data']);
}
I think it's because a lot of data is transported like that from different apis and it's a good idea to store the payload from an api before starting to process it. Just like there is an option to store xml in a column.
I'm not saying that it isn't sometimes useful to store json in the database just that it should only store more or less static data that you don't update or search for.