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

Work with the specific payee (not subject's user) #42

Closed
jadamec opened this issue Nov 23, 2020 · 4 comments
Closed

Work with the specific payee (not subject's user) #42

jadamec opened this issue Nov 23, 2020 · 4 comments

Comments

@jadamec
Copy link

jadamec commented Nov 23, 2020

$post = auth()->user()->posts()->create($request->all()); // id: 1
$user = User::find(2); // id: 2

Why this method adds points to the user with the id: 1, and not on which it is pointing? What's the reason of the $user, then?
$user->givePoint(new PostCreated($post));

@blakekrone
Copy link

From what I can tell the givePoint helper function (helpers.php) can set the appropriate model, but the problem is once you get into the givePoint function from HasReputations.php where it finally calls to attach to the payee() things are lost. Been scratching my head on this for a bit today trying to figure it out as not all my models will have a direct user() relationship, most are through many to many.

@jadamec
Copy link
Author

jadamec commented Dec 4, 2020

In my project, I figured it out by passing a $user to these functions, ignoring payee() completely. Works like a charm!

@jadamec jadamec closed this as completed Dec 4, 2020
@blakekrone
Copy link

Would be nice to get a more elegant solution put in as a PR though to make it work as expected!

@blakekrone
Copy link

I just added a pull request for how I did it. #43

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

2 participants