Skip to content

Commit d1af6f6

Browse files
committed
Added new accesor to get the balance amount transformed to currency.
1 parent 688a630 commit d1af6f6

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to `laravel-balance` will be documented in this file
44

5+
## 1.0.2 - 2021-03-26
6+
7+
- Added new accesor to get the balance amount transformed to currency.
8+
59
## 1.0.0 - 2021-03-19
610

711
- initial release

src/Balance.php

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ public function __construct(array $attributes = [])
3030
$this->setTable(config('balance.table', 'balance_history'));
3131
}
3232

33+
/**
34+
* Get the balance amount transformed to currency.
35+
*
36+
* @return float|int
37+
*/
38+
public function getAmountAttribute()
39+
{
40+
return $this->attributes['amount'] / 100;
41+
}
42+
3343
/**
3444
* Get the parent of the balance record.
3545
*

src/HasBalance.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait HasBalance
99
/**
1010
* Get the model's balance amount.
1111
*
12-
* @return int
12+
* @return float|int
1313
*/
1414
public function getBalanceAttribute()
1515
{

0 commit comments

Comments
 (0)