$city = City::with('station')->where('name',$town)->first();
$townID = 1;
$townComments = TownComment::where('town_id',$townID)->get();
$city->town_comments = $townComments;
When I do this, the result for the town_comments
only shows boolean
for the timestamps
, incrementing
and exists
.
What am I doing wrong here?
here is how it looks like:
{
id: "1",
name: "tokyo",
similar_stations: {
timestamps: false,
incrementing: true,
exists: true
}
}
It's being displayed like that because $townComments
is an object automatically encoded to JSON
, I forgot the reference where I read it but this is the solution.
$city->town_comments = $townComments->toArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With