我想从问题中排除question_type_id
。请帮帮我。
[
{
"template_id": 2,
"title": "news surey2345",
"instructions": " this is news surey2345",
"reference": "a426a9288424ff3d540115ffc38bd0b4",
"status_id": 1,
"published_date": "2017-03-30 11:12:48",
"expiry_date": null,
"survey_template": {
"is_public": 0,
"submission_type": 1,
"id": 2
},
"questiongroup": [
{
"survey_id": 17,
"title": "question group 2",
"instructions": " this is question group 2",
"has_free_text": 1,
"sort": 4,
"id": 19,
"question": [
{
"id": 58,
"question_type_id": 1,
"question_group_id": 19,
"title": "question3",
"can_upload_file": 0,
"can_comment": 0,
"include_na_answer": 1,
"sort": 31,
"question_answers": [
{
"question_id": 58,
"answer": "answer1",
"points": "12",
"id": 206
},
{
"question_id": 58,
"answer": "answer2",
"points": "11",
"id": 207
},
{
"question_id": 58,
"answer": "NA",
"points": "0",
"id": 208
}
],
"question_type": {
"slug": "multi-choice",
"id": 1
}
},
{
"id": 134,
"question_type_id": 1,
"question_group_id": 19,
"title": "question3",
"can_upload_file": 0,
"can_comment": 0,
"include_na_answer": 1,
"sort": 33,
"question_answers": [],
"question_type": {
"slug": "multi-choice",
"id": 1
}
},
{
"id": 161,
"question_type_id": 1,
"question_group_id": 19,
"title": "question3",
"can_upload_file": 0,
"can_comment": 0,
"include_na_answer": 1,
"sort": 34,
"question_answers": [],
"question_type": {
"slug": "multi-choice",
"id": 1
}
},
{
"id": 165,
"question_type_id": 1,
"question_group_id": 19,
"title": "question3",
"can_upload_file": 0,
"can_comment": 0,
"include_na_answer": 1,
"sort": 35,
"question_answers": [],
"question_type": {
"slug": "multi-choice",
"id": 1
}
}
]
}
]
}
]
答案 0 :(得分:2)
class MyModel extends Model {
protected $hidden = ['question_type_id'];
}
您可以向$hidden
属性添加属性,以防止在将模型转换为JSON时显示该属性。