cybercog / laravel-love

Add Social Reactions to Laravel Eloquent Models. It lets people express how they feel about the content. Fully customizable Weighted Reaction System & Reaction Type System with Like, Dislike and any other custom emotion types. Do you react?

Home Page:https://komarev.com/sources/laravel-love

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Method Illuminate\Database\Eloquent\Collection::viaLoveReactant does not exist.

bertux77 opened this issue · comments

Hello everyone,

I am trying to implement this package, which I must say is costing me quite a lot as I haven't seen any tutorial explaining it. So I take this opportunity to suggest that you post a tutorial or at least a working demo on Github that we can download for testing.

That said, I would like to see why I get this error, I'm trying to return the total likes but I get this error:

BadMethodCallException
Method Illuminate\Database\Eloquent\Collection::viaLoveReactant does not exist.

The code with which I am trying to access the total is:

$comment = Comment::where('id', "232")->get(); // return comment
return $comment->viaLoveReactant()->getReactionCounters();

Method get returns collection of comments, not an actual comment.

$comment = Comment::where('id', "232")->firstOrFail();
return $comment->viaLoveReactant()->getReactionCounters();