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

Potential fix for assigning the user model instead of using auth #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Console/stubs/point.stub
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class DummyClass extends PointType
*/
public function payee()
{
return $this->getSubject()->user;
if (property_exists($this, 'payee')) {
return $this->payee;
}
else
{
return $this->getSubject()->user;
}
}
}
1 change: 1 addition & 0 deletions src/HasReputations.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ trait HasReputations
*/
public function givePoint(PointType $pointType)
{
$pointType->setPayee($this);
if (!$pointType->qualifier()) {
return false;
}
Expand Down
13 changes: 12 additions & 1 deletion src/PointType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ abstract class PointType
* @var Model
*/
protected $subject;
protected $payee;

/**
* Check qualification to give this point
Expand All @@ -36,7 +37,7 @@ public function qualifier()
public function payee()
{
if (property_exists($this, 'payee')) {
return $this->getSubject()->{$this->payee};
return $this->payee;
}

throw new InvalidPayeeModel();
Expand Down Expand Up @@ -93,6 +94,16 @@ public function setSubject($subject)
$this->subject = $subject;
}

/**
* Set a payee
*
* @param mixed $payee
*/
public function setPayee($payee)
{
$this->payee = $payee;
}

/**
* Check if reputation alredy exists for a point
*
Expand Down