diff --git a/src/Console/stubs/point.stub b/src/Console/stubs/point.stub index 0a9b9e6..ce626f4 100644 --- a/src/Console/stubs/point.stub +++ b/src/Console/stubs/point.stub @@ -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; + } } } diff --git a/src/HasReputations.php b/src/HasReputations.php index 8b46717..3da930f 100644 --- a/src/HasReputations.php +++ b/src/HasReputations.php @@ -14,6 +14,7 @@ trait HasReputations */ public function givePoint(PointType $pointType) { + $pointType->setPayee($this); if (!$pointType->qualifier()) { return false; } diff --git a/src/PointType.php b/src/PointType.php index 2ef2c49..c7b9df4 100644 --- a/src/PointType.php +++ b/src/PointType.php @@ -17,6 +17,7 @@ abstract class PointType * @var Model */ protected $subject; + protected $payee; /** * Check qualification to give this point @@ -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(); @@ -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 *