Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a little help understanding the Likable trait #11

Open
jayenne opened this issue Oct 12, 2020 · 0 comments
Open

a little help understanding the Likable trait #11

jayenne opened this issue Oct 12, 2020 · 0 comments

Comments

@jayenne
Copy link

jayenne commented 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

    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.

@jayenne jayenne changed the title a little help understanding the likes trait a little help understanding the Likable trait Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant