Add formatted_amount accessor to both Earning and Spending models
MODIFY
app/Earning.php
app/Earning.php
@@ -6,4 +6,12 @@ use Illuminate\Database\Eloquent\Model;
class Earning extends Model {
public $timestamps = false;
+
+ // Accessors
+ public function getFormattedAmountAttribute() {
+ return number_format($this->amount / 100, 2);
+ }
+
+ // Relations
+ //
}

MODIFY
app/Spending.php
app/Spending.php
@@ -7,6 +7,12 @@ use Illuminate\Database\Eloquent\Model;
class Spending extends Model {
public $timestamps = false;
+ // Accessors
+ public function getFormattedAmountAttribute() {
+ return number_format($this->amount / 100, 2);
+ }
+
+ // Relations
public function tag() {
return $this->belongsTo('App\Tag');
}

Add formatted_amount accessor to both Earning and Spending models