7
$city = City::with('station')->where('name',$town)->first();
$townID = 1;
$townComments = TownComment::where('town_id',$townID)->get();
$city->town_comments = $townComments;

当我这样做时,仅town_comments显示boolean,和的结果。timestampsincrementingexists

我在这里做错了什么?

这是它的样子:

{
id: "1",
name: "tokyo",
similar_stations: {
    timestamps: false,
    incrementing: true,
    exists: true
}
}
4

1 回答 1

19

它之所以这样显示,是因为$townComments它是一个自动编码为的对象JSON,我忘记了阅读它的参考,但这是解决方案。

$city->town_comments = $townComments->toArray();
于 2013-07-24T06:27:03.863 回答