Skip to content

Commit

Permalink
Merge pull request #42 from yuriymartini/master
Browse files Browse the repository at this point in the history
[FIX] Update Rewardable.php
  • Loading branch information
zgabievi authored Jan 23, 2019
2 parents 2de7fc2 + 1eb954d commit 024674f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Traits/Rewardable.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public function applyCode($code, $callback = null)
{
try {
if ($promocode = Promocodes::check($code)) {
if ($promocode->users()->wherePivot('user_id', $this->id)->exists()) {
if ($promocode->users()->wherePivot(config('promocodes.related_pivot_key'), $this->id)->exists()) {
throw new AlreadyUsedException;
}

$promocode->users()->attach($this->id, [
'promocode_id' => $promocode->id,
config('promocodes.foreign_pivot_key') => $promocode->id,
'used_at' => Carbon::now(),
]);

Expand Down

0 comments on commit 024674f

Please sign in to comment.