-
Notifications
You must be signed in to change notification settings - Fork 112
Description
I've added parent_id to tweets as a means to include tweets as comments too.
I've added a parent() and children() method to the Tweet model
public function children()
{
return $this->hasMany('App\Tweet', 'parent_id')->with('children');
}
But when I add ->withCount('children') to the timeline() method it foobar's the ->withLikes() method. instead of a number for likes & dislikes I get json string of the likes array instead.
[{"id":1,"user_id":1,"tweet_id":50,"liked":1,"created_at":"2020-10-12T20:24:10.000000Z","updated_at":"2020-10-12T20:27:00.000000Z"},{"id":3,"user_id":2,"tweet_id":50,"liked":1,"created_at":"2020-10-12T20:24:29.000000Z","updated_at":"2020-10-12T20:24:29.000000Z"}]
My questions is, why does this happen? is it someinthg in the Likable trait that doesn't like the withCount or the possiblitiy is nesting? or other?
I know and appreiacite it is a little off-topic so any help would be cool.