Comments (6)
Hey, @saqueib,
This is an awsome package, unfortunately i'm having this same issue, which is that calling
Auth::user()->givePoint(new GroupCommentCreated($comment));
results in
payee() method must return a model which will get the points.
.
The problem is when calling the method givePoint
on a user class ( in my case Auth::user()
), it still tries to find the payee using the payee() function of the PointType Class , which is redundant in my opinion.
The expected behaviour in this situation is to give the points to the user on which the givePoint methond has been executed.
from laravel-gamify.
Share your ProjectCreated point class
from laravel-gamify.
Thanks for your prompt reply. My ProjectCreated class is as follows:
<?php
namespace App\Gamify\Points;
use QCod\Gamify\PointType;
class ProjectCreated extends PointType
{
/**
* Number of points
*
* @var int
*/
public $points = 20;
/**
* Point constructor
*
* @param $subject
*/
public function __construct($subject)
{
$this->subject = $subject;
}
/**
* User who will be receive points
*
* @return mixed
*/
public function payee()
{
return $this->getSubject()->user;
}
}
from laravel-gamify.
make sure Project
model has a belongsTo
on the User model. and try this at last
// Creates the project
$project = Project::create($attributes);
// Rewards points
givePoint(new ProjectCreated($project->fresh()));
from laravel-gamify.
Hey @saqueib,
Thanks for your reply. I have figured out the issue with my case which is that my Project model has a method called owner() instead of user(). By changing from owner() to user(), it works now.
For the benefit of others who might be facing the same error message, ensure that your model has the user() method as such:
Project Model:
public function user()
{
return $this->belongsTo(User::class);
}
from laravel-gamify.
The expected behaviour in this situation is to give the points to the user on which the givePoint methond has been executed.
I must agreee with you @walidbagh . How can I achieve that, please (even by writing a custom PointType class). Thanks!
#42
from laravel-gamify.
Related Issues (20)
- Give points when badge is earned? HOT 1
- Feature: Morph support for Payee HOT 2
- Is this package still being maintained? HOT 2
- Can we extend the badge qualifier HOT 1
- Payee is not getting the user parameter HOT 3
- Laravel 8 Support HOT 1
- payee() method must return a model which will get the points HOT 3
- #ASK - How to call Notifications Got Awards
- From postaman ok, from webapp error HOT 2
- Work with the specific payee (not subject's user) HOT 4
- Use without Badge If your app doesn't need Badges you should just use HasReputations trait instead of Gamify. HOT 1
- Remove ShouldBroadcast from ReputationChanged event HOT 1
- Laravel octane
- Support Laravel 9.0 ? HOT 1
- How can I turn off the Info Logging HOT 1
- Populating meta column
- Can't give point to User HOT 1
- Give Points to another User HOT 1
- Leaderboard Position
- undoPoint() is not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-gamify.