🤖 Auto commit for release 'develop' on 2025-09-15

This commit is contained in:
JC5
2025-09-15 05:23:47 +02:00
parent 9075fa8ac8
commit de9efb0727
65 changed files with 416 additions and 408 deletions

View File

@@ -50,9 +50,9 @@ class Account extends Model
use ReturnsIntegerUserIdTrait;
use SoftDeletes;
protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban', 'native_virtual_balance'];
protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban', 'native_virtual_balance'];
protected $hidden = ['encrypted'];
protected $hidden = ['encrypted'];
private bool $joinedAccountTypes = false;
/**
@@ -66,10 +66,10 @@ class Account extends Model
$accountId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|Account $account */
$account = $user->accounts()->with(['accountType'])->find($accountId);
$account = $user->accounts()->with(['accountType'])->find($accountId);
if (null !== $account) {
return $account;
}
@@ -126,7 +126,7 @@ class Account extends Model
public function setVirtualBalanceAttribute(mixed $value): void
{
$value = (string)$value;
$value = (string)$value;
if ('' === $value) {
$value = null;
}
@@ -146,7 +146,7 @@ class Account extends Model
protected function accountId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -158,8 +158,9 @@ class Account extends Model
return Attribute::make(get: function () {
/** @var null|AccountMeta $metaValue */
$metaValue = $this->accountMeta()
->where('name', 'account_number')
->first();
->where('name', 'account_number')
->first()
;
return null !== $metaValue ? $metaValue->data : '';
});
@@ -176,7 +177,7 @@ class Account extends Model
protected function accountTypeId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -220,14 +221,14 @@ class Account extends Model
protected function iban(): Attribute
{
return Attribute::make(
get: static fn($value) => null === $value ? null : trim(str_replace(' ', '', (string)$value)),
get: static fn ($value) => null === $value ? null : trim(str_replace(' ', '', (string)$value)),
);
}
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -237,7 +238,7 @@ class Account extends Model
protected function virtualBalance(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
}

View File

@@ -27,6 +27,7 @@ use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use function Safe\json_decode;
use function Safe\json_encode;
@@ -52,6 +53,6 @@ class AccountMeta extends Model
protected function data(): Attribute
{
return Attribute::make(get: fn(mixed $value) => (string)json_decode((string)$value, true), set: fn(mixed $value) => ['data' => json_encode($value)]);
return Attribute::make(get: fn (mixed $value) => (string)json_decode((string)$value, true), set: fn (mixed $value) => ['data' => json_encode($value)]);
}
}

View File

@@ -34,39 +34,39 @@ class AccountType extends Model
#[Deprecated]
/** @deprecated */
public const string ASSET = 'Asset account';
public const string ASSET = 'Asset account';
#[Deprecated]
/** @deprecated */
public const string BENEFICIARY = 'Beneficiary account';
public const string BENEFICIARY = 'Beneficiary account';
#[Deprecated]
/** @deprecated */
public const string CASH = 'Cash account';
public const string CASH = 'Cash account';
#[Deprecated]
/** @deprecated */
public const string CREDITCARD = 'Credit card';
public const string CREDITCARD = 'Credit card';
#[Deprecated]
/** @deprecated */
public const string DEBT = 'Debt';
public const string DEBT = 'Debt';
#[Deprecated]
/** @deprecated */
public const string DEFAULT = 'Default account';
public const string DEFAULT = 'Default account';
#[Deprecated]
/** @deprecated */
public const string EXPENSE = 'Expense account';
public const string EXPENSE = 'Expense account';
#[Deprecated]
/** @deprecated */
public const string IMPORT = 'Import account';
public const string IMPORT = 'Import account';
#[Deprecated]
/** @deprecated */
public const string INITIAL_BALANCE = 'Initial balance account';
public const string INITIAL_BALANCE = 'Initial balance account';
#[Deprecated]
/** @deprecated */
@@ -74,27 +74,27 @@ class AccountType extends Model
#[Deprecated]
/** @deprecated */
public const string LOAN = 'Loan';
public const string LOAN = 'Loan';
#[Deprecated]
/** @deprecated */
public const string MORTGAGE = 'Mortgage';
public const string MORTGAGE = 'Mortgage';
#[Deprecated]
/** @deprecated */
public const string RECONCILIATION = 'Reconciliation account';
public const string RECONCILIATION = 'Reconciliation account';
#[Deprecated]
/** @deprecated */
public const string REVENUE = 'Revenue account';
public const string REVENUE = 'Revenue account';
protected $casts
= [
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
protected $fillable = ['type'];
protected $fillable = ['type'];
public function accounts(): HasMany
{

View File

@@ -56,10 +56,10 @@ class Attachment extends Model
$attachmentId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|Attachment $attachment */
$attachment = $user->attachments()->find($attachmentId);
$attachment = $user->attachments()->find($attachmentId);
if (null !== $attachment) {
return $attachment;
}
@@ -100,7 +100,7 @@ class Attachment extends Model
protected function attachableId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}

View File

@@ -48,7 +48,7 @@ class AuditLogEntry extends Model
protected function auditableId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -66,7 +66,7 @@ class AuditLogEntry extends Model
protected function changerId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -45,17 +45,17 @@ class AutoBudget extends Model
#[Deprecated]
/** @deprecated */
public const int AUTO_BUDGET_RESET = 1;
public const int AUTO_BUDGET_RESET = 1;
#[Deprecated]
/** @deprecated */
public const int AUTO_BUDGET_ROLLOVER = 2;
protected $casts
= [
= [
'amount' => 'string',
'native_amount' => 'string',
];
protected $fillable = ['budget_id', 'amount', 'period', 'native_amount'];
protected $fillable = ['budget_id', 'amount', 'period', 'native_amount'];
public function budget(): BelongsTo
{
@@ -70,14 +70,14 @@ class AutoBudget extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
protected function budgetId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -91,7 +91,7 @@ class AutoBudget extends Model
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -55,10 +55,10 @@ class AvailableBudget extends Model
$availableBudgetId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|AvailableBudget $availableBudget */
$availableBudget = $user->availableBudgets()->find($availableBudgetId);
$availableBudget = $user->availableBudgets()->find($availableBudgetId);
if (null !== $availableBudget) {
return $availableBudget;
}
@@ -80,7 +80,7 @@ class AvailableBudget extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
@@ -103,23 +103,23 @@ class AvailableBudget extends Model
protected function endDate(): Attribute
{
return Attribute::make(
get: fn(string $value) => Carbon::parse($value),
set: fn(Carbon $value) => $value->format('Y-m-d'),
get: fn (string $value) => Carbon::parse($value),
set: fn (Carbon $value) => $value->format('Y-m-d'),
);
}
protected function startDate(): Attribute
{
return Attribute::make(
get: fn(string $value) => Carbon::parse($value),
set: fn(Carbon $value) => $value->format('Y-m-d'),
get: fn (string $value) => Carbon::parse($value),
set: fn (Carbon $value) => $value->format('Y-m-d'),
);
}
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -46,7 +46,7 @@ class Bill extends Model
use SoftDeletes;
protected $fillable
= [
= [
'name',
'match',
'amount_min',
@@ -81,10 +81,10 @@ class Bill extends Model
$billId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|Bill $bill */
$bill = $user->bills()->find($billId);
$bill = $user->bills()->find($billId);
if (null !== $bill) {
return $bill;
}
@@ -151,7 +151,7 @@ class Bill extends Model
protected function amountMax(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
@@ -161,7 +161,7 @@ class Bill extends Model
protected function amountMin(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
@@ -189,7 +189,7 @@ class Bill extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -199,14 +199,14 @@ class Bill extends Model
protected function skip(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -46,7 +46,7 @@ class Budget extends Model
protected $fillable = ['user_id', 'user_group_id', 'name', 'active', 'order', 'user_group_id'];
protected $hidden = ['encrypted'];
protected $hidden = ['encrypted'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
@@ -59,10 +59,10 @@ class Budget extends Model
$budgetId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|Budget $budget */
$budget = $user->budgets()->find($budgetId);
$budget = $user->budgets()->find($budgetId);
if (null !== $budget) {
return $budget;
}
@@ -125,7 +125,7 @@ class Budget extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -50,9 +50,10 @@ class BudgetLimit extends Model
if (auth()->check()) {
$budgetLimitId = (int)$value;
$budgetLimit = self::where('budget_limits.id', $budgetLimitId)
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->where('budgets.user_id', auth()->user()->id)
->first(['budget_limits.*']);
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->where('budgets.user_id', auth()->user()->id)
->first(['budget_limits.*'])
;
if (null !== $budgetLimit) {
return $budgetLimit;
}
@@ -85,14 +86,14 @@ class BudgetLimit extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
protected function budgetId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -112,7 +113,7 @@ class BudgetLimit extends Model
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -45,7 +45,7 @@ class Category extends Model
protected $fillable = ['user_id', 'user_group_id', 'name'];
protected $hidden = ['encrypted'];
protected $hidden = ['encrypted'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
@@ -58,10 +58,10 @@ class Category extends Model
$categoryId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|Category $category */
$category = $user->categories()->find($categoryId);
$category = $user->categories()->find($categoryId);
if (null !== $category) {
return $category;
}

View File

@@ -27,6 +27,7 @@ use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use function Safe\json_decode;
use function Safe\json_encode;
@@ -51,6 +52,6 @@ class Configuration extends Model
*/
protected function data(): Attribute
{
return Attribute::make(get: fn($value) => json_decode((string)$value), set: fn($value) => ['data' => json_encode($value)]);
return Attribute::make(get: fn ($value) => json_decode((string)$value), set: fn ($value) => ['data' => json_encode($value)]);
}
}

View File

@@ -73,28 +73,28 @@ class CurrencyExchangeRate extends Model
protected function fromCurrencyId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function rate(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
protected function toCurrencyId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function userRate(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
}

View File

@@ -66,7 +66,7 @@ class GroupMembership extends Model
protected function userRoleId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -48,7 +48,7 @@ class InvitedUser extends Model
$attemptId = (int)$value;
/** @var null|InvitedUser $attempt */
$attempt = self::find($attemptId);
$attempt = self::find($attemptId);
if (null !== $attempt) {
return $attempt;
}

View File

@@ -81,7 +81,7 @@ class Location extends Model
protected function locatableId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -56,7 +56,7 @@ class Note extends Model
protected function noteableId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -51,8 +51,9 @@ class ObjectGroup extends Model
$objectGroupId = (int)$value;
/** @var null|ObjectGroup $objectGroup */
$objectGroup = self::where('object_groups.id', $objectGroupId)
->where('object_groups.user_id', auth()->user()->id)->first();
$objectGroup = self::where('object_groups.id', $objectGroupId)
->where('object_groups.user_id', auth()->user()->id)->first()
;
if (null !== $objectGroup) {
return $objectGroup;
}
@@ -104,7 +105,7 @@ class ObjectGroup extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -54,9 +54,10 @@ class PiggyBank extends Model
if (auth()->check()) {
$piggyBankId = (int)$value;
$piggyBank = self::where('piggy_banks.id', $piggyBankId)
->leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*']);
->leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*'])
;
if (null !== $piggyBank) {
return $piggyBank;
}
@@ -122,7 +123,7 @@ class PiggyBank extends Model
protected function accountId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -145,7 +146,7 @@ class PiggyBank extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -155,7 +156,7 @@ class PiggyBank extends Model
protected function targetAmount(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
}

View File

@@ -38,7 +38,7 @@ class PiggyBankEvent extends Model
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'date_tz', 'amount', 'native_amount'];
protected $hidden = ['amount_encrypted'];
protected $hidden = ['amount_encrypted'];
public function piggyBank(): BelongsTo
{
@@ -64,7 +64,7 @@ class PiggyBankEvent extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
@@ -82,7 +82,7 @@ class PiggyBankEvent extends Model
protected function piggyBankId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -68,7 +68,7 @@ class PiggyBankRepetition extends Model
protected function currentAmount(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
@@ -81,7 +81,7 @@ class PiggyBankRepetition extends Model
protected function piggyBankId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -97,11 +97,12 @@ class PiggyBankRepetition extends Model
$q->orWhereNull('start_date');
}
)
->where(
static function (EloquentBuilder $q) use ($date): void {
$q->where('target_date', '>=', $date->format('Y-m-d 00:00:00'));
$q->orWhereNull('target_date');
}
);
->where(
static function (EloquentBuilder $q) use ($date): void {
$q->where('target_date', '>=', $date->format('Y-m-d 00:00:00'));
$q->orWhereNull('target_date');
}
)
;
}
}

View File

@@ -46,7 +46,7 @@ class Preference extends Model
{
if (auth()->check()) {
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
// some preferences do not have an administration ID.
// some need it, to make sure the correct one is selected.
@@ -54,8 +54,8 @@ class Preference extends Model
$userGroupId = 0 === $userGroupId ? null : $userGroupId;
/** @var null|Preference $preference */
$preference = null;
$items = config('firefly.admin_specific_prefs');
$preference = null;
$items = config('firefly.admin_specific_prefs');
if (null !== $userGroupId && in_array($value, $items, true)) {
// find a preference with a specific user_group_id
$preference = $user->preferences()->where('user_group_id', $userGroupId)->where('name', $value)->first();
@@ -73,7 +73,7 @@ class Preference extends Model
/** @var Preference $preference */
return $preference;
}
$default = config('firefly.default_preferences');
$default = config('firefly.default_preferences');
if (array_key_exists($value, $default)) {
$preference = new self();
$preference->name = $value;

View File

@@ -46,7 +46,7 @@ class Recurrence extends Model
use SoftDeletes;
protected $fillable
= ['user_id', 'user_group_id', 'transaction_type_id', 'title', 'description', 'first_date', 'first_date_tz', 'repeat_until', 'repeat_until_tz', 'latest_date', 'latest_date_tz', 'repetitions', 'apply_rules', 'active'];
= ['user_id', 'user_group_id', 'transaction_type_id', 'title', 'description', 'first_date', 'first_date_tz', 'repeat_until', 'repeat_until_tz', 'latest_date', 'latest_date_tz', 'repetitions', 'apply_rules', 'active'];
protected $table = 'recurrences';
@@ -61,10 +61,10 @@ class Recurrence extends Model
$recurrenceId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|Recurrence $recurrence */
$recurrence = $user->recurrences()->find($recurrenceId);
$recurrence = $user->recurrences()->find($recurrenceId);
if (null !== $recurrence) {
return $recurrence;
}
@@ -139,7 +139,7 @@ class Recurrence extends Model
protected function transactionTypeId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -37,7 +37,7 @@ class RecurrenceMeta extends Model
protected $fillable = ['recurrence_id', 'name', 'value'];
protected $table = 'recurrences_meta';
protected $table = 'recurrences_meta';
public function recurrence(): BelongsTo
{
@@ -58,7 +58,7 @@ class RecurrenceMeta extends Model
protected function recurrenceId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -38,7 +38,7 @@ class RecurrenceRepetition extends Model
#[Deprecated]
/** @deprecated */
public const int WEEKEND_DO_NOTHING = 1;
public const int WEEKEND_DO_NOTHING = 1;
#[Deprecated]
/** @deprecated */
@@ -46,14 +46,14 @@ class RecurrenceRepetition extends Model
#[Deprecated]
/** @deprecated */
public const int WEEKEND_TO_FRIDAY = 3;
public const int WEEKEND_TO_FRIDAY = 3;
#[Deprecated]
/** @deprecated */
public const int WEEKEND_TO_MONDAY = 4;
public const int WEEKEND_TO_MONDAY = 4;
protected $casts
= [
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
@@ -63,9 +63,9 @@ class RecurrenceRepetition extends Model
'weekend' => 'int',
];
protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip'];
protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip'];
protected $table = 'recurrences_repetitions';
protected $table = 'recurrences_repetitions';
public function recurrence(): BelongsTo
{
@@ -82,21 +82,21 @@ class RecurrenceRepetition extends Model
protected function recurrenceId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function repetitionSkip(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function weekend(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -40,7 +40,7 @@ class RecurrenceTransaction extends Model
use SoftDeletes;
protected $fillable
= [
= [
'recurrence_id',
'transaction_currency_id',
'foreign_currency_id',
@@ -91,7 +91,7 @@ class RecurrenceTransaction extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
@@ -110,42 +110,42 @@ class RecurrenceTransaction extends Model
protected function destinationId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function foreignAmount(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
protected function recurrenceId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function sourceId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function userId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -37,7 +37,7 @@ class RecurrenceTransactionMeta extends Model
protected $fillable = ['rt_id', 'name', 'value'];
protected $table = 'rt_meta';
protected $table = 'rt_meta';
public function recurrenceTransaction(): BelongsTo
{
@@ -58,7 +58,7 @@ class RecurrenceTransactionMeta extends Model
protected function rtId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -55,10 +55,10 @@ class Rule extends Model
$ruleId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|Rule $rule */
$rule = $user->rules()->find($ruleId);
$rule = $user->rules()->find($ruleId);
if (null !== $rule) {
return $rule;
}
@@ -110,20 +110,20 @@ class Rule extends Model
protected function description(): Attribute
{
return Attribute::make(set: fn($value) => ['description' => e($value)]);
return Attribute::make(set: fn ($value) => ['description' => e($value)]);
}
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function ruleGroupId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -80,14 +80,14 @@ class RuleAction extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function ruleId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -55,10 +55,10 @@ class RuleGroup extends Model
$ruleGroupId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|RuleGroup $ruleGroup */
$ruleGroup = $user->ruleGroups()->find($ruleGroupId);
$ruleGroup = $user->ruleGroups()->find($ruleGroupId);
if (null !== $ruleGroup) {
return $ruleGroup;
}
@@ -94,7 +94,7 @@ class RuleGroup extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -53,14 +53,14 @@ class RuleTrigger extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function ruleId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -45,7 +45,7 @@ class Tag extends Model
protected $fillable = ['user_id', 'user_group_id', 'tag', 'date', 'date_tz', 'description', 'tag_mode'];
protected $hidden = ['zoomLevel', 'zoom_level', 'latitude', 'longitude'];
protected $hidden = ['zoomLevel', 'zoom_level', 'latitude', 'longitude'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
@@ -58,10 +58,10 @@ class Tag extends Model
$tagId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|Tag $tag */
$tag = $user->tags()->find($tagId);
$tag = $user->tags()->find($tagId);
if (null !== $tag) {
return $tag;
}

View File

@@ -44,7 +44,7 @@ class Transaction extends Model
use SoftDeletes;
protected $fillable
= [
= [
'account_id',
'transaction_journal_id',
'description',
@@ -113,7 +113,7 @@ class Transaction extends Model
protected function accountId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
@@ -151,14 +151,14 @@ class Transaction extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
protected function balanceDirty(): Attribute
{
return Attribute::make(
get: static fn($value) => 1 === (int)$value,
get: static fn ($value) => 1 === (int)$value,
);
}
@@ -201,14 +201,14 @@ class Transaction extends Model
protected function foreignAmount(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
protected function transactionJournalId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}

View File

@@ -40,7 +40,7 @@ class TransactionCurrency extends Model
public ?bool $userGroupEnabled = null;
public ?bool $userGroupNative = null;
protected $fillable = ['name', 'code', 'symbol', 'decimal_places', 'enabled'];
protected $fillable = ['name', 'code', 'symbol', 'decimal_places', 'enabled'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
@@ -115,7 +115,7 @@ class TransactionCurrency extends Model
protected function decimalPlaces(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -55,13 +55,14 @@ class TransactionGroup extends Model
$groupId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
app('log')->debug(sprintf('User authenticated as %s', $user->email));
/** @var null|TransactionGroup $group */
$group = $user->transactionGroups()
->with(['transactionJournals', 'transactionJournals.transactions'])
->where('transaction_groups.id', $groupId)->first(['transaction_groups.*']);
$group = $user->transactionGroups()
->with(['transactionJournals', 'transactionJournals.transactions'])
->where('transaction_groups.id', $groupId)->first(['transaction_groups.*'])
;
if (null !== $group) {
app('log')->debug(sprintf('Found group #%d.', $group->id));

View File

@@ -57,7 +57,7 @@ class TransactionJournal extends Model
use SoftDeletes;
protected $fillable
= [
= [
'user_id',
'user_group_id',
'transaction_type_id',
@@ -84,10 +84,10 @@ class TransactionJournal extends Model
$journalId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|TransactionJournal $journal */
$journal = $user->transactionJournals()->where('transaction_journals.id', $journalId)->first(['transaction_journals.*']);
$journal = $user->transactionJournals()->where('transaction_journals.id', $journalId)->first(['transaction_journals.*']);
if (null !== $journal) {
return $journal;
}
@@ -230,14 +230,14 @@ class TransactionJournal extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function transactionTypeId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}

View File

@@ -46,11 +46,12 @@ class TransactionJournalLink extends Model
if (auth()->check()) {
$linkId = (int)$value;
$link = self::where('journal_links.id', $linkId)
->leftJoin('transaction_journals as t_a', 't_a.id', '=', 'source_id')
->leftJoin('transaction_journals as t_b', 't_b.id', '=', 'destination_id')
->where('t_a.user_id', auth()->user()->id)
->where('t_b.user_id', auth()->user()->id)
->first(['journal_links.*']);
->leftJoin('transaction_journals as t_a', 't_a.id', '=', 'source_id')
->leftJoin('transaction_journals as t_b', 't_b.id', '=', 'destination_id')
->where('t_a.user_id', auth()->user()->id)
->where('t_b.user_id', auth()->user()->id)
->first(['journal_links.*'])
;
if (null !== $link) {
return $link;
}
@@ -93,21 +94,21 @@ class TransactionJournalLink extends Model
protected function destinationId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function linkTypeId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
protected function sourceId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -28,6 +28,7 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use function Safe\json_decode;
use function Safe\json_encode;
@@ -38,7 +39,7 @@ class TransactionJournalMeta extends Model
protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash'];
protected $table = 'journal_meta';
protected $table = 'journal_meta';
public function transactionJournal(): BelongsTo
{
@@ -56,7 +57,7 @@ class TransactionJournalMeta extends Model
protected function data(): Attribute
{
return Attribute::make(get: fn($value) => json_decode((string)$value, false), set: function ($value) {
return Attribute::make(get: fn ($value) => json_decode((string)$value, false), set: function ($value) {
$data = json_encode($value);
return ['data' => $data, 'hash' => hash('sha256', $data)];
@@ -66,7 +67,7 @@ class TransactionJournalMeta extends Model
protected function transactionJournalId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -38,11 +38,11 @@ class TransactionType extends Model
#[Deprecated]
/** @deprecated */
public const string DEPOSIT = 'Deposit';
public const string DEPOSIT = 'Deposit';
#[Deprecated]
/** @deprecated */
public const string INVALID = 'Invalid';
public const string INVALID = 'Invalid';
#[Deprecated]
/** @deprecated */
@@ -50,27 +50,27 @@ class TransactionType extends Model
#[Deprecated]
/** @deprecated */
public const string OPENING_BALANCE = 'Opening balance';
public const string OPENING_BALANCE = 'Opening balance';
#[Deprecated]
/** @deprecated */
public const string RECONCILIATION = 'Reconciliation';
public const string RECONCILIATION = 'Reconciliation';
#[Deprecated]
/** @deprecated */
public const string TRANSFER = 'Transfer';
public const string TRANSFER = 'Transfer';
#[Deprecated]
/** @deprecated */
public const string WITHDRAWAL = 'Withdrawal';
public const string WITHDRAWAL = 'Withdrawal';
protected $casts
= [
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
protected $fillable = ['type'];
protected $fillable = ['type'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).

View File

@@ -50,16 +50,16 @@ class UserGroup extends Model
$userGroupId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|UserGroup $userGroup */
$userGroup = self::find($userGroupId);
$userGroup = self::find($userGroupId);
if (null === $userGroup) {
throw new NotFoundHttpException();
}
// need at least ready only to be aware of the user group's existence,
// but owner/full role (in the group) or global owner role may overrule this.
$access = $user->hasRoleInGroupOrOwner($userGroup, UserRoleEnum::READ_ONLY) || $user->hasRole('owner');
$access = $user->hasRoleInGroupOrOwner($userGroup, UserRoleEnum::READ_ONLY) || $user->hasRole('owner');
if ($access) {
return $userGroup;
}

View File

@@ -137,10 +137,10 @@ class Webhook extends Model
$webhookId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|Webhook $webhook */
$webhook = $user->webhooks()->find($webhookId);
$webhook = $user->webhooks()->find($webhookId);
if (null !== $webhook) {
return $webhook;
}

View File

@@ -48,10 +48,10 @@ class WebhookAttempt extends Model
$attemptId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|WebhookAttempt $attempt */
$attempt = self::find($attemptId);
$attempt = self::find($attemptId);
if (null !== $attempt && $attempt->webhookMessage->webhook->user_id === $user->id) {
return $attempt;
}
@@ -68,7 +68,7 @@ class WebhookAttempt extends Model
protected function webhookMessageId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -41,7 +41,7 @@ class WebhookDelivery extends Model
protected function key(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -50,10 +50,10 @@ class WebhookMessage extends Model
$messageId = (int)$value;
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
/** @var null|WebhookMessage $message */
$message = self::find($messageId);
$message = self::find($messageId);
if (null !== $message && $message->webhook->user_id === $user->id) {
return $message;
}
@@ -89,14 +89,14 @@ class WebhookMessage extends Model
protected function sent(): Attribute
{
return Attribute::make(
get: static fn($value) => (bool)$value,
get: static fn ($value) => (bool)$value,
);
}
protected function webhookId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -41,7 +41,7 @@ class WebhookResponse extends Model
protected function key(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}

View File

@@ -41,7 +41,7 @@ class WebhookTrigger extends Model
protected function key(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}