mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 10:53:37 +00:00
Add attributes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AvailableBudget.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -24,6 +25,7 @@ namespace FireflyIII\Models;
|
||||
|
||||
use Eloquent;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -96,7 +98,7 @@ class AvailableBudget extends Model
|
||||
public static function routeBinder(string $value): AvailableBudget
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$availableBudgetId = (int) $value;
|
||||
$availableBudgetId = (int)$value;
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var AvailableBudget $availableBudget */
|
||||
@@ -125,4 +127,14 @@ class AvailableBudget extends Model
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ namespace FireflyIII\Models;
|
||||
use Eloquent;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -99,4 +100,24 @@ class CurrencyExchangeRate extends Model
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function rate(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => (string) $value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function userRate(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => (string) $value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -164,4 +165,24 @@ class RecurrenceTransaction extends Model
|
||||
{
|
||||
return $this->belongsTo(TransactionType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => (string) $value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function foreignAmount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => (string) $value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user