mercredi 2 mars 2016

Modify Eloquent cast JSON to attributes

My Eloquent model has an attribute/column called "group_answers" which is a json representation of additional custom questions and answers, like;

{
  "satisfied_with_course":"3",
  "satisfied_with_teacher":"5",
  "satisfied_with_residence":"2", 
}

Is it possible to alter the Model so that I have additional attributes for each key? That can be called like $model->satisfied_with_course instead of $model->group_answers['satisfied_with_course']?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire