You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
jayenne
changed the title
a little help understanding the likes trait
a little help understanding the Likable trait
Oct 12, 2020
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
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.
The text was updated successfully, but these errors were encountered: