Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

monicahq/monica

23656 stars
3 code files
View monicahq/monica on GitHub

app/Traits/AmountFormatter.php

Open in GitHub
use App\Helpers\MoneyHelper;
use App\Models\Settings\Currency;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
trait AmountFormatter
{
public function currency()
{
return $this->belongsTo(Currency::class);
}
 
public function setAmountAttribute($value)
{
$this->attributes['amount'] = MoneyHelper::parseInput($value, $this->currency);
}
//
}

app/Models/Contact/Debt.php

Open in GitHub
use App\Traits\AmountFormatter;
 
class Debt extends Model
{
use AmountFormatter;
//
}

resources/views/people/debt/form.blade.php

Open in GitHub
//
{{-- Amount --}}
<div class="form-group">
<label for="amount">{{ trans('people.debt_add_amount') }} ({{ Auth::user()->currency->symbol }})</label>
<input type="number" step=".01" class="form-control" name="amount" id="amount" maxlength="254" value="{{ old('amount') ?? $debt->amount }}" autofocus required>
</div>
//

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.