Skip to content

Commit

Permalink
updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Trexology committed Feb 4, 2016
1 parent 06192ee commit 59db508
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $user = User::first();
$user->transactions;

//OR
//$user['transactions'] = $user->transactions(2)->get(); //Get last 2 transaction
//$user['transactions'] = $user->transactions(2)->get(); //Get last 2 transactions

dd($user);
```
Expand Down
25 changes: 12 additions & 13 deletions src/Models/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,20 @@ public function pointable()
*
* @return static
*/
public function getCurrentPoints(Model $pointable)
{
$trans = Transaction::
where('pointable_id', $pointable->id)
->where('pointable_type', get_class($pointable))
->orderBy('created_at', 'desc')
->first(['current']);
public function getCurrentPoints(Model $pointable)
{
$currentPoint = Transaction::
where('pointable_id', $pointable->id)
->where('pointable_type', get_class($pointable))
->orderBy('created_at', 'desc')
->pluck('current');

$currentPoint = $trans->current;
if (!$currentPoint) {
$currentPoint = 0.0;
}
if (!$currentPoint) {
$currentPoint = 0.0;
}

return $currentPoint;
}
return $currentPoint;
}

/**
* @param Model $pointable
Expand Down

0 comments on commit 59db508

Please sign in to comment.