$city = City::with('station')->where('name',$town)->first();
$townID = 1;
$townComments = TownComment::where('town_id',$townID)->get();
$city->town_comments = $townComments;
当我这样做时,town_comments
的结果仅显示timestamps
、incrementing
和exists
的boolean
。
我在这里做错了什么?
下面是它的外观:
{
id: "1",
name: "tokyo",
similar_stations: {
timestamps: false,
incrementing: true,
exists: true
}
}
之所以这样显示$townComments
是因为它是一个自动编码为JSON
的对象,我忘记了阅读它的参考,但这是解决方案。
$city->town_comments = $townComments->toArray();