mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Code cleanup.
This commit is contained in:
@@ -44,40 +44,41 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class Account
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $account_type_id
|
||||
* @property string $name
|
||||
* @property string $virtual_balance
|
||||
* @property string|null $iban
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int $order
|
||||
* @property-read Collection|AccountMeta[] $accountMeta
|
||||
* @property-read int|null $account_meta_count
|
||||
* @property AccountType $accountType
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read string $account_number
|
||||
* @property-read string $edit_name
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|ObjectGroup[] $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read Collection|PiggyBank[] $piggyBanks
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $account_type_id
|
||||
* @property string $name
|
||||
* @property string $virtual_balance
|
||||
* @property null|string $iban
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int $order
|
||||
* @property AccountMeta[]|Collection $accountMeta
|
||||
* @property null|int $account_meta_count
|
||||
* @property AccountType $accountType
|
||||
* @property Attachment[]|Collection $attachments
|
||||
* @property null|int $attachments_count
|
||||
* @property string $account_number
|
||||
* @property string $edit_name
|
||||
* @property Collection|Location[] $locations
|
||||
* @property null|int $locations_count
|
||||
* @property Collection|Note[] $notes
|
||||
* @property null|int $notes_count
|
||||
* @property Collection|ObjectGroup[] $objectGroups
|
||||
* @property null|int $object_groups_count
|
||||
* @property Collection|PiggyBank[] $piggyBanks
|
||||
* @property null|int $piggy_banks_count
|
||||
* @property Collection|Transaction[] $transactions
|
||||
* @property null|int $transactions_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static EloquentBuilder|Account accountTypeIn($types)
|
||||
* @method static EloquentBuilder|Account newModelQuery()
|
||||
* @method static EloquentBuilder|Account newQuery()
|
||||
* @method static Builder|Account onlyTrashed()
|
||||
* @method static Builder|Account onlyTrashed()
|
||||
* @method static EloquentBuilder|Account query()
|
||||
* @method static EloquentBuilder|Account whereAccountTypeId($value)
|
||||
* @method static EloquentBuilder|Account whereActive($value)
|
||||
@@ -91,21 +92,25 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static EloquentBuilder|Account whereUpdatedAt($value)
|
||||
* @method static EloquentBuilder|Account whereUserId($value)
|
||||
* @method static EloquentBuilder|Account whereVirtualBalance($value)
|
||||
* @method static Builder|Account withTrashed()
|
||||
* @method static Builder|Account withoutTrashed()
|
||||
* @property Carbon $lastActivityDate
|
||||
* @property string $startBalance
|
||||
* @property string $endBalance
|
||||
* @property string $difference
|
||||
* @property string $interest
|
||||
* @property string $interestPeriod
|
||||
* @property string $accountTypeString
|
||||
* @property Location $location
|
||||
* @property string $liability_direction
|
||||
* @property string $current_debt
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|Account withTrashed()
|
||||
* @method static Builder|Account withoutTrashed()
|
||||
*
|
||||
* @property Carbon $lastActivityDate
|
||||
* @property string $startBalance
|
||||
* @property string $endBalance
|
||||
* @property string $difference
|
||||
* @property string $interest
|
||||
* @property string $interestPeriod
|
||||
* @property string $accountTypeString
|
||||
* @property Location $location
|
||||
* @property string $liability_direction
|
||||
* @property string $current_debt
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static EloquentBuilder|Account whereUserGroupId($value)
|
||||
* @property-read UserGroup|null $userGroup
|
||||
*
|
||||
* @property null|UserGroup $userGroup
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Account extends Model
|
||||
@@ -133,45 +138,36 @@ class Account extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Account
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$accountId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Account|null $account */
|
||||
|
||||
/** @var null|Account $account */
|
||||
$account = $user->accounts()->with(['accountType'])->find($accountId);
|
||||
if (null !== $account) {
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function accountType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AccountType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
@@ -179,30 +175,23 @@ class Account extends Model
|
||||
|
||||
/**
|
||||
* Get the account number.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountNumberAttribute(): string
|
||||
{
|
||||
/** @var AccountMeta|null $metaValue */
|
||||
/** @var null|AccountMeta $metaValue */
|
||||
$metaValue = $this->accountMeta()
|
||||
->where('name', 'account_number')
|
||||
->first();
|
||||
->where('name', 'account_number')
|
||||
->first()
|
||||
;
|
||||
|
||||
return null !== $metaValue ? $metaValue->data : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function accountMeta(): HasMany
|
||||
{
|
||||
return $this->hasMany(AccountMeta::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEditNameAttribute(): string
|
||||
{
|
||||
$name = $this->name;
|
||||
@@ -214,9 +203,6 @@ class Account extends Model
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function locations(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Location::class, 'locatable');
|
||||
@@ -238,19 +224,11 @@ class Account extends Model
|
||||
return $this->morphToMany(ObjectGroup::class, 'object_groupable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function piggyBanks(): HasMany
|
||||
{
|
||||
return $this->hasMany(PiggyBank::class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeAccountTypeIn(EloquentBuilder $query, array $types): void
|
||||
{
|
||||
if (false === $this->joinedAccountTypes) {
|
||||
@@ -260,12 +238,6 @@ class Account extends Model
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
|
||||
*/
|
||||
public function setVirtualBalanceAttribute(mixed $value): void
|
||||
{
|
||||
$value = (string)$value;
|
||||
@@ -275,64 +247,47 @@ class Account extends Model
|
||||
$this->attributes['virtual_balance'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Transaction::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function userGroup(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(UserGroup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function accountId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user ID
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function accountTypeId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the virtual balance
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function virtualBalance(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,13 +33,14 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
/**
|
||||
* Class AccountMeta
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int $account_id
|
||||
* @property string $name
|
||||
* @property mixed $data
|
||||
* @property-read Account $account
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property int $account_id
|
||||
* @property string $name
|
||||
* @property mixed $data
|
||||
* @property Account $account
|
||||
*
|
||||
* @method static Builder|AccountMeta newModelQuery()
|
||||
* @method static Builder|AccountMeta newQuery()
|
||||
* @method static Builder|AccountMeta query()
|
||||
@@ -49,6 +50,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @method static Builder|AccountMeta whereId($value)
|
||||
* @method static Builder|AccountMeta whereName($value)
|
||||
* @method static Builder|AccountMeta whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class AccountMeta extends Model
|
||||
@@ -62,33 +64,22 @@ class AccountMeta extends Model
|
||||
];
|
||||
|
||||
protected $fillable = ['account_id', 'name', 'data'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'account_meta';
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function account(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Account::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataAttribute(mixed $value): string
|
||||
{
|
||||
return (string)json_decode($value, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setDataAttribute(mixed $value): void
|
||||
{
|
||||
$this->attributes['data'] = json_encode($value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,12 +34,13 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
/**
|
||||
* FireflyIII\Models\AccountType
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string $type
|
||||
* @property-read Collection|Account[] $accounts
|
||||
* @property-read int|null $accounts_count
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property Account[]|Collection $accounts
|
||||
* @property null|int $accounts_count
|
||||
*
|
||||
* @method static Builder|AccountType newModelQuery()
|
||||
* @method static Builder|AccountType newQuery()
|
||||
* @method static Builder|AccountType query()
|
||||
@@ -47,6 +48,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
* @method static Builder|AccountType whereId($value)
|
||||
* @method static Builder|AccountType whereType($value)
|
||||
* @method static Builder|AccountType whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class AccountType extends Model
|
||||
@@ -68,7 +70,6 @@ class AccountType extends Model
|
||||
public const string RECONCILIATION = 'Reconciliation account';
|
||||
public const string REVENUE = 'Revenue account';
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -77,13 +78,8 @@ class AccountType extends Model
|
||||
|
||||
protected $fillable = ['type'];
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function accounts(): HasMany
|
||||
{
|
||||
return $this->hasMany(Account::class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -41,29 +41,30 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\Attachment
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $attachable_id
|
||||
* @property string $attachable_type
|
||||
* @property bool $file_exists
|
||||
* @property string $md5
|
||||
* @property string $filename
|
||||
* @property string|null $title
|
||||
* @property string|null $description
|
||||
* @property string $mime
|
||||
* @property int|string $size
|
||||
* @property bool $uploaded
|
||||
* @property string $notes_text
|
||||
* @property-read Model|Eloquent $attachable
|
||||
* @property Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $attachable_id
|
||||
* @property string $attachable_type
|
||||
* @property bool $file_exists
|
||||
* @property string $md5
|
||||
* @property string $filename
|
||||
* @property null|string $title
|
||||
* @property null|string $description
|
||||
* @property string $mime
|
||||
* @property int|string $size
|
||||
* @property bool $uploaded
|
||||
* @property string $notes_text
|
||||
* @property \Eloquent|Model $attachable
|
||||
* @property Collection|Note[] $notes
|
||||
* @property null|int $notes_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment newQuery()
|
||||
* @method static Builder|Attachment onlyTrashed()
|
||||
* @method static Builder|Attachment onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereAttachableId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereAttachableType($value)
|
||||
@@ -79,10 +80,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUploaded($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUserId($value)
|
||||
* @method static Builder|Attachment withTrashed()
|
||||
* @method static Builder|Attachment withoutTrashed()
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|Attachment withTrashed()
|
||||
* @method static Builder|Attachment withoutTrashed()
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUserGroupId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Attachment extends Model
|
||||
@@ -104,29 +108,26 @@ class Attachment extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Attachment
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$attachmentId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Attachment|null $attachment */
|
||||
|
||||
/** @var null|Attachment $attachment */
|
||||
$attachment = $user->attachments()->find($attachmentId);
|
||||
if (null !== $attachment) {
|
||||
return $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
@@ -134,9 +135,6 @@ class Attachment extends Model
|
||||
|
||||
/**
|
||||
* Get all of the owning attachable models.
|
||||
*
|
||||
*
|
||||
* @return MorphTo
|
||||
*/
|
||||
public function attachable(): MorphTo
|
||||
{
|
||||
@@ -145,8 +143,6 @@ class Attachment extends Model
|
||||
|
||||
/**
|
||||
* Returns the expected filename for this attachment.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fileName(): string
|
||||
{
|
||||
@@ -161,14 +157,10 @@ class Attachment extends Model
|
||||
return $this->morphMany(Note::class, 'noteable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function attachableId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,25 +36,28 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
/**
|
||||
* Class AuditLogEntry
|
||||
*
|
||||
* @property-read Model|Eloquent $auditable
|
||||
* @property-read Model|Eloquent $changer
|
||||
* @method static Builder|AuditLogEntry newModelQuery()
|
||||
* @method static Builder|AuditLogEntry newQuery()
|
||||
* @property \Eloquent|Model $auditable
|
||||
* @property \Eloquent|Model $changer
|
||||
*
|
||||
* @method static Builder|AuditLogEntry newModelQuery()
|
||||
* @method static Builder|AuditLogEntry newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|AuditLogEntry onlyTrashed()
|
||||
* @method static Builder|AuditLogEntry query()
|
||||
* @method static Builder|AuditLogEntry query()
|
||||
* @method static \Illuminate\Database\Query\Builder|AuditLogEntry withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|AuditLogEntry withoutTrashed()
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $auditable_id
|
||||
* @property string $auditable_type
|
||||
* @property int $changer_id
|
||||
* @property string $changer_type
|
||||
* @property string $action
|
||||
* @property array|null $before
|
||||
* @property array|null $after
|
||||
*
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $auditable_id
|
||||
* @property string $auditable_type
|
||||
* @property int $changer_id
|
||||
* @property string $changer_type
|
||||
* @property string $action
|
||||
* @property null|array $before
|
||||
* @property null|array $after
|
||||
*
|
||||
* @method static Builder|AuditLogEntry whereAction($value)
|
||||
* @method static Builder|AuditLogEntry whereAfter($value)
|
||||
* @method static Builder|AuditLogEntry whereAuditableId($value)
|
||||
@@ -66,6 +69,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @method static Builder|AuditLogEntry whereDeletedAt($value)
|
||||
* @method static Builder|AuditLogEntry whereId($value)
|
||||
* @method static Builder|AuditLogEntry whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class AuditLogEntry extends Model
|
||||
@@ -82,39 +86,27 @@ class AuditLogEntry extends Model
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
*/
|
||||
public function auditable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function changer(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function auditableId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function changerId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -36,20 +36,21 @@ use Illuminate\Database\Query\Builder;
|
||||
/**
|
||||
* FireflyIII\Models\AutoBudget
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $budget_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property int|string $auto_budget_type
|
||||
* @property string $amount
|
||||
* @property string $period
|
||||
* @property-read Budget $budget
|
||||
* @property-read TransactionCurrency $transactionCurrency
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $budget_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property int|string $auto_budget_type
|
||||
* @property string $amount
|
||||
* @property string $period
|
||||
* @property Budget $budget
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget newQuery()
|
||||
* @method static Builder|AutoBudget onlyTrashed()
|
||||
* @method static Builder|AutoBudget onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereAutoBudgetType($value)
|
||||
@@ -60,8 +61,9 @@ use Illuminate\Database\Query\Builder;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget wherePeriod($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereTransactionCurrencyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget whereUpdatedAt($value)
|
||||
* @method static Builder|AutoBudget withTrashed()
|
||||
* @method static Builder|AutoBudget withoutTrashed()
|
||||
* @method static Builder|AutoBudget withTrashed()
|
||||
* @method static Builder|AutoBudget withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class AutoBudget extends Model
|
||||
@@ -74,50 +76,34 @@ class AutoBudget extends Model
|
||||
public const int AUTO_BUDGET_ROLLOVER = 2;
|
||||
protected $fillable = ['budget_id', 'amount', 'period'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function budget(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Budget::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function budgetId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,20 +38,21 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\AvailableBudget
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property string $amount
|
||||
* @property Carbon $start_date
|
||||
* @property Carbon $end_date
|
||||
* @property-read TransactionCurrency $transactionCurrency
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property string $amount
|
||||
* @property Carbon $start_date
|
||||
* @property Carbon $end_date
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
* @property User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget newQuery()
|
||||
* @method static Builder|AvailableBudget onlyTrashed()
|
||||
* @method static Builder|AvailableBudget onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereCreatedAt($value)
|
||||
@@ -62,10 +63,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereTransactionCurrencyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereUserId($value)
|
||||
* @method static Builder|AvailableBudget withTrashed()
|
||||
* @method static Builder|AvailableBudget withoutTrashed()
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|AvailableBudget withTrashed()
|
||||
* @method static Builder|AvailableBudget withoutTrashed()
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereUserGroupId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class AvailableBudget extends Model
|
||||
@@ -89,60 +93,47 @@ class AvailableBudget extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return AvailableBudget
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$availableBudgetId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var AvailableBudget|null $availableBudget */
|
||||
|
||||
/** @var null|AvailableBudget $availableBudget */
|
||||
$availableBudget = $user->availableBudgets()->find($availableBudgetId);
|
||||
if (null !== $availableBudget) {
|
||||
return $availableBudget;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,39 +42,40 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\Bill
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property string $name
|
||||
* @property string $match
|
||||
* @property string $amount_min
|
||||
* @property string $amount_max
|
||||
* @property Carbon $date
|
||||
* @property Carbon|null $end_date
|
||||
* @property Carbon|null $extension_date
|
||||
* @property string $repeat_freq
|
||||
* @property int $skip
|
||||
* @property bool $automatch
|
||||
* @property bool $active
|
||||
* @property bool $name_encrypted
|
||||
* @property bool $match_encrypted
|
||||
* @property int $order
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|ObjectGroup[] $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read TransactionCurrency|null $transactionCurrency
|
||||
* @property-read Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property string $name
|
||||
* @property string $match
|
||||
* @property string $amount_min
|
||||
* @property string $amount_max
|
||||
* @property Carbon $date
|
||||
* @property null|Carbon $end_date
|
||||
* @property null|Carbon $extension_date
|
||||
* @property string $repeat_freq
|
||||
* @property int $skip
|
||||
* @property bool $automatch
|
||||
* @property bool $active
|
||||
* @property bool $name_encrypted
|
||||
* @property bool $match_encrypted
|
||||
* @property int $order
|
||||
* @property Attachment[]|Collection $attachments
|
||||
* @property null|int $attachments_count
|
||||
* @property Collection|Note[] $notes
|
||||
* @property null|int $notes_count
|
||||
* @property Collection|ObjectGroup[] $objectGroups
|
||||
* @property null|int $object_groups_count
|
||||
* @property null|TransactionCurrency $transactionCurrency
|
||||
* @property Collection|TransactionJournal[] $transactionJournals
|
||||
* @property null|int $transaction_journals_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill newQuery()
|
||||
* @method static Builder|Bill onlyTrashed()
|
||||
* @method static Builder|Bill onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereAmountMax($value)
|
||||
@@ -96,10 +97,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereTransactionCurrencyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserId($value)
|
||||
* @method static Builder|Bill withTrashed()
|
||||
* @method static Builder|Bill withoutTrashed()
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|Bill withTrashed()
|
||||
* @method static Builder|Bill withoutTrashed()
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserGroupId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Bill extends Model
|
||||
@@ -123,7 +127,6 @@ class Bill extends Model
|
||||
'match_encrypted' => 'boolean',
|
||||
];
|
||||
|
||||
|
||||
protected $fillable
|
||||
= [
|
||||
'name',
|
||||
@@ -147,37 +150,31 @@ class Bill extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Bill
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$billId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Bill|null $bill */
|
||||
|
||||
/** @var null|Bill $bill */
|
||||
$bill = $user->bills()->find($billId);
|
||||
if (null !== $bill) {
|
||||
return $bill;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
@@ -200,7 +197,6 @@ class Bill extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setAmountMaxAttribute($value): void
|
||||
@@ -210,25 +206,17 @@ class Bill extends Model
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
|
||||
*/
|
||||
public function setAmountMinAttribute($value): void
|
||||
{
|
||||
$this->attributes['amount_min'] = (string)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactionJournals(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournal::class);
|
||||
@@ -236,59 +224,45 @@ class Bill extends Model
|
||||
|
||||
/**
|
||||
* Get the max amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amountMax(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the min amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amountMin(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the skip
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function skip(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -42,29 +42,30 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\Budget
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int $order
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection|AutoBudget[] $autoBudgets
|
||||
* @property-read int|null $auto_budgets_count
|
||||
* @property-read Collection|BudgetLimit[] $budgetlimits
|
||||
* @property-read int|null $budgetlimits_count
|
||||
* @property-read Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int $order
|
||||
* @property Attachment[]|Collection $attachments
|
||||
* @property null|int $attachments_count
|
||||
* @property AutoBudget[]|Collection $autoBudgets
|
||||
* @property null|int $auto_budgets_count
|
||||
* @property BudgetLimit[]|Collection $budgetlimits
|
||||
* @property null|int $budgetlimits_count
|
||||
* @property Collection|TransactionJournal[] $transactionJournals
|
||||
* @property null|int $transaction_journals_count
|
||||
* @property Collection|Transaction[] $transactions
|
||||
* @property null|int $transactions_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Budget newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Budget newQuery()
|
||||
* @method static Builder|Budget onlyTrashed()
|
||||
* @method static Builder|Budget onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Budget query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Budget whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Budget whereCreatedAt($value)
|
||||
@@ -75,13 +76,17 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Budget whereOrder($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Budget whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Budget whereUserId($value)
|
||||
* @method static Builder|Budget withTrashed()
|
||||
* @method static Builder|Budget withoutTrashed()
|
||||
* @property string $email
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|Budget withTrashed()
|
||||
* @method static Builder|Budget withoutTrashed()
|
||||
*
|
||||
* @property string $email
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Budget whereUserGroupId($value)
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
*
|
||||
* @property Collection|Note[] $notes
|
||||
* @property null|int $notes_count
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Budget extends Model
|
||||
@@ -106,53 +111,41 @@ class Budget extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Budget
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$budgetId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Budget|null $budget */
|
||||
|
||||
/** @var null|Budget $budget */
|
||||
$budget = $user->budgets()->find($budgetId);
|
||||
if (null !== $budget) {
|
||||
return $budget;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function autoBudgets(): HasMany
|
||||
{
|
||||
return $this->hasMany(AutoBudget::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function budgetlimits(): HasMany
|
||||
{
|
||||
return $this->hasMany(BudgetLimit::class);
|
||||
@@ -166,30 +159,20 @@ class Budget extends Model
|
||||
return $this->morphMany(Note::class, 'noteable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function transactionJournals(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(TransactionJournal::class, 'budget_transaction_journal', 'budget_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function transactions(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,19 +38,20 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\BudgetLimit
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int $budget_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property Carbon $start_date
|
||||
* @property Carbon|null $end_date
|
||||
* @property string $amount
|
||||
* @property string $spent
|
||||
* @property string|null $period
|
||||
* @property int|string $generated
|
||||
* @property-read Budget $budget
|
||||
* @property-read TransactionCurrency|null $transactionCurrency
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property int $budget_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property Carbon $start_date
|
||||
* @property null|Carbon $end_date
|
||||
* @property string $amount
|
||||
* @property string $spent
|
||||
* @property null|string $period
|
||||
* @property int|string $generated
|
||||
* @property Budget $budget
|
||||
* @property null|TransactionCurrency $transactionCurrency
|
||||
*
|
||||
* @method static Builder|BudgetLimit newModelQuery()
|
||||
* @method static Builder|BudgetLimit newQuery()
|
||||
* @method static Builder|BudgetLimit query()
|
||||
@@ -64,6 +65,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|BudgetLimit whereStartDate($value)
|
||||
* @method static Builder|BudgetLimit whereTransactionCurrencyId($value)
|
||||
* @method static Builder|BudgetLimit whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class BudgetLimit extends Model
|
||||
@@ -90,9 +92,6 @@ class BudgetLimit extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return BudgetLimit
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
@@ -100,27 +99,23 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function budget(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Budget::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
@@ -128,35 +123,25 @@ class BudgetLimit extends Model
|
||||
|
||||
/**
|
||||
* Get the amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function budgetId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,26 +40,27 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\Category
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property Carbon $lastActivity
|
||||
* @property bool $encrypted
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property Carbon $lastActivity
|
||||
* @property bool $encrypted
|
||||
* @property Attachment[]|Collection $attachments
|
||||
* @property null|int $attachments_count
|
||||
* @property Collection|Note[] $notes
|
||||
* @property null|int $notes_count
|
||||
* @property Collection|TransactionJournal[] $transactionJournals
|
||||
* @property null|int $transaction_journals_count
|
||||
* @property Collection|Transaction[] $transactions
|
||||
* @property null|int $transactions_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category newQuery()
|
||||
* @method static Builder|Category onlyTrashed()
|
||||
* @method static Builder|Category onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category whereDeletedAt($value)
|
||||
@@ -68,10 +69,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category whereUserId($value)
|
||||
* @method static Builder|Category withTrashed()
|
||||
* @method static Builder|Category withoutTrashed()
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|Category withTrashed()
|
||||
* @method static Builder|Category withoutTrashed()
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category whereUserGroupId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Category extends Model
|
||||
@@ -95,37 +99,31 @@ class Category extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Category
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$categoryId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Category|null $category */
|
||||
|
||||
/** @var null|Category $category */
|
||||
$category = $user->categories()->find($categoryId);
|
||||
if (null !== $category) {
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
@@ -139,20 +137,13 @@ class Category extends Model
|
||||
return $this->morphMany(Note::class, 'noteable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function transactionJournals(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(TransactionJournal::class, 'category_transaction_journal', 'category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function transactions(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Transaction::class, 'category_transaction', 'category_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,14 +34,15 @@ use Illuminate\Database\Query\Builder;
|
||||
* FireflyIII\Models\Configuration
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property string $name
|
||||
* @property mixed $data
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Configuration newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Configuration newQuery()
|
||||
* @method static Builder|Configuration onlyTrashed()
|
||||
* @method static Builder|Configuration onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Configuration query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Configuration whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Configuration whereData($value)
|
||||
@@ -49,8 +50,9 @@ use Illuminate\Database\Query\Builder;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Configuration whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Configuration whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Configuration whereUpdatedAt($value)
|
||||
* @method static Builder|Configuration withTrashed()
|
||||
* @method static Builder|Configuration withoutTrashed()
|
||||
* @method static Builder|Configuration withTrashed()
|
||||
* @method static Builder|Configuration withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Configuration extends Model
|
||||
@@ -58,20 +60,19 @@ class Configuration extends Model
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'configuration';
|
||||
|
||||
/**
|
||||
* TODO can be replaced with native laravel code.
|
||||
*
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed
|
||||
@@ -82,13 +83,10 @@ class Configuration extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setDataAttribute($value): void
|
||||
{
|
||||
$this->attributes['data'] = json_encode($value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -37,19 +37,20 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
/**
|
||||
* Class CurrencyExchangeRate
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $from_currency_id
|
||||
* @property int $to_currency_id
|
||||
* @property Carbon $date
|
||||
* @property string $rate
|
||||
* @property string $user_rate
|
||||
* @property-read TransactionCurrency $fromCurrency
|
||||
* @property-read TransactionCurrency $toCurrency
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|string $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $from_currency_id
|
||||
* @property int $to_currency_id
|
||||
* @property Carbon $date
|
||||
* @property string $rate
|
||||
* @property string $user_rate
|
||||
* @property TransactionCurrency $fromCurrency
|
||||
* @property TransactionCurrency $toCurrency
|
||||
* @property User $user
|
||||
*
|
||||
* @method static Builder|CurrencyExchangeRate newModelQuery()
|
||||
* @method static Builder|CurrencyExchangeRate newQuery()
|
||||
* @method static Builder|CurrencyExchangeRate query()
|
||||
@@ -63,11 +64,14 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @method static Builder|CurrencyExchangeRate whereUpdatedAt($value)
|
||||
* @method static Builder|CurrencyExchangeRate whereUserId($value)
|
||||
* @method static Builder|CurrencyExchangeRate whereUserRate($value)
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static Builder|CurrencyExchangeRate whereUserGroupId($value)
|
||||
* @method static Builder|CurrencyExchangeRate onlyTrashed()
|
||||
* @method static Builder|CurrencyExchangeRate withTrashed()
|
||||
* @method static Builder|CurrencyExchangeRate withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class CurrencyExchangeRate extends Model
|
||||
@@ -76,81 +80,57 @@ class CurrencyExchangeRate extends Model
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'user_id' => 'int',
|
||||
'from_currency_id' => 'int',
|
||||
'to_currency_id' => 'int',
|
||||
'date' => 'datetime',
|
||||
];
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'user_id' => 'int',
|
||||
'from_currency_id' => 'int',
|
||||
'to_currency_id' => 'int',
|
||||
'date' => 'datetime',
|
||||
];
|
||||
protected $fillable = ['user_id', 'from_currency_id', 'to_currency_id', 'date', 'rate'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function fromCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class, 'from_currency_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function toCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class, 'to_currency_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function fromCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function rate(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function toCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function userRate(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -37,16 +37,17 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
/**
|
||||
* Class GroupMembership
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $user_group_id
|
||||
* @property int $user_role_id
|
||||
* @property-read User $user
|
||||
* @property-read UserGroup $userGroup
|
||||
* @property-read UserRole $userRole
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|string $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $user_group_id
|
||||
* @property int $user_role_id
|
||||
* @property User $user
|
||||
* @property UserGroup $userGroup
|
||||
* @property UserRole $userRole
|
||||
*
|
||||
* @method static Builder|GroupMembership newModelQuery()
|
||||
* @method static Builder|GroupMembership newQuery()
|
||||
* @method static Builder|GroupMembership query()
|
||||
@@ -57,6 +58,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @method static Builder|GroupMembership whereUserGroupId($value)
|
||||
* @method static Builder|GroupMembership whereUserId($value)
|
||||
* @method static Builder|GroupMembership whereUserRoleId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class GroupMembership extends Model
|
||||
@@ -66,39 +68,25 @@ class GroupMembership extends Model
|
||||
|
||||
protected $fillable = ['user_id', 'user_group_id', 'user_role_id'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function userGroup(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(UserGroup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function userRole(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(UserRole::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function userRoleId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -37,18 +37,21 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class InvitedUser
|
||||
*
|
||||
* @property-read User $user
|
||||
* @property User $user
|
||||
*
|
||||
* @method static Builder|InvitedUser newModelQuery()
|
||||
* @method static Builder|InvitedUser newQuery()
|
||||
* @method static Builder|InvitedUser query()
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property int $user_id
|
||||
* @property string $email
|
||||
* @property string $invite_code
|
||||
* @property Carbon $expires
|
||||
* @property bool $redeemed
|
||||
*
|
||||
* @method static Builder|InvitedUser whereCreatedAt($value)
|
||||
* @method static Builder|InvitedUser whereEmail($value)
|
||||
* @method static Builder|InvitedUser whereExpires($value)
|
||||
@@ -57,6 +60,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|InvitedUser whereRedeemed($value)
|
||||
* @method static Builder|InvitedUser whereUpdatedAt($value)
|
||||
* @method static Builder|InvitedUser whereUserId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class InvitedUser extends Model
|
||||
@@ -66,38 +70,31 @@ class InvitedUser extends Model
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'expires' => 'datetime',
|
||||
'redeemed' => 'boolean',
|
||||
];
|
||||
'expires' => 'datetime',
|
||||
'redeemed' => 'boolean',
|
||||
];
|
||||
protected $fillable = ['user_id', 'email', 'invite_code', 'expires', 'redeemed'];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return InvitedUser
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$attemptId = (int)$value;
|
||||
/** @var InvitedUser|null $attempt */
|
||||
|
||||
/** @var null|InvitedUser $attempt */
|
||||
$attempt = self::find($attemptId);
|
||||
if (null !== $attempt) {
|
||||
return $attempt;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -36,20 +36,21 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\LinkType
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property string $name
|
||||
* @property string $outward
|
||||
* @property string $inward
|
||||
* @property int $journalCount
|
||||
* @property bool $editable
|
||||
* @property-read Collection|TransactionJournalLink[] $transactionJournalLinks
|
||||
* @property-read int|null $transaction_journal_links_count
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property string $name
|
||||
* @property string $outward
|
||||
* @property string $inward
|
||||
* @property int $journalCount
|
||||
* @property bool $editable
|
||||
* @property Collection|TransactionJournalLink[] $transactionJournalLinks
|
||||
* @property null|int $transaction_journal_links_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|LinkType newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|LinkType newQuery()
|
||||
* @method static Builder|LinkType onlyTrashed()
|
||||
* @method static Builder|LinkType onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|LinkType query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|LinkType whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|LinkType whereDeletedAt($value)
|
||||
@@ -59,8 +60,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|LinkType whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|LinkType whereOutward($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|LinkType whereUpdatedAt($value)
|
||||
* @method static Builder|LinkType withTrashed()
|
||||
* @method static Builder|LinkType withoutTrashed()
|
||||
* @method static Builder|LinkType withTrashed()
|
||||
* @method static Builder|LinkType withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class LinkType extends Model
|
||||
@@ -68,7 +70,6 @@ class LinkType extends Model
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -77,16 +78,11 @@ class LinkType extends Model
|
||||
'editable' => 'boolean',
|
||||
];
|
||||
|
||||
|
||||
protected $fillable = ['name', 'inward', 'outward', 'editable'];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return LinkType
|
||||
*
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
@@ -98,16 +94,12 @@ class LinkType extends Model
|
||||
return $linkType;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactionJournalLinks(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournalLink::class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -37,18 +37,19 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
/**
|
||||
* FireflyIII\Models\Location
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $locatable_id
|
||||
* @property string $locatable_type
|
||||
* @property float|null $latitude
|
||||
* @property float|null $longitude
|
||||
* @property int|null $zoom_level
|
||||
* @property-read Collection|Account[] $accounts
|
||||
* @property-read int|null $accounts_count
|
||||
* @property-read Model|Eloquent $locatable
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $locatable_id
|
||||
* @property string $locatable_type
|
||||
* @property null|float $latitude
|
||||
* @property null|float $longitude
|
||||
* @property null|int $zoom_level
|
||||
* @property Account[]|Collection $accounts
|
||||
* @property null|int $accounts_count
|
||||
* @property \Eloquent|Model $locatable
|
||||
*
|
||||
* @method static Builder|Location newModelQuery()
|
||||
* @method static Builder|Location newQuery()
|
||||
* @method static Builder|Location query()
|
||||
@@ -61,6 +62,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
* @method static Builder|Location whereLongitude($value)
|
||||
* @method static Builder|Location whereUpdatedAt($value)
|
||||
* @method static Builder|Location whereZoomLevel($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Location extends Model
|
||||
@@ -81,10 +83,6 @@ class Location extends Model
|
||||
|
||||
/**
|
||||
* Add rules for locations.
|
||||
*
|
||||
* @param array $rules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function requestRules(array $rules): array
|
||||
{
|
||||
@@ -105,24 +103,16 @@ class Location extends Model
|
||||
|
||||
/**
|
||||
* Get all the owning attachable models.
|
||||
*
|
||||
*
|
||||
* @return MorphTo
|
||||
*/
|
||||
public function locatable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function locatableId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,18 +35,19 @@ use Illuminate\Database\Query\Builder;
|
||||
/**
|
||||
* FireflyIII\Models\Note
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $noteable_id
|
||||
* @property string $noteable_type
|
||||
* @property string|null $title
|
||||
* @property string|null $text
|
||||
* @property-read Model|Eloquent $noteable
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $noteable_id
|
||||
* @property string $noteable_type
|
||||
* @property null|string $title
|
||||
* @property null|string $text
|
||||
* @property \Eloquent|Model $noteable
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Note newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Note newQuery()
|
||||
* @method static Builder|Note onlyTrashed()
|
||||
* @method static Builder|Note onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Note query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Note whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Note whereDeletedAt($value)
|
||||
@@ -56,8 +57,9 @@ use Illuminate\Database\Query\Builder;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Note whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Note whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Note whereUpdatedAt($value)
|
||||
* @method static Builder|Note withTrashed()
|
||||
* @method static Builder|Note withoutTrashed()
|
||||
* @method static Builder|Note withTrashed()
|
||||
* @method static Builder|Note withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Note extends Model
|
||||
@@ -65,7 +67,6 @@ class Note extends Model
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -76,7 +77,6 @@ class Note extends Model
|
||||
protected $fillable = ['title', 'text', 'noteable_id', 'noteable_type'];
|
||||
|
||||
/**
|
||||
*
|
||||
* Get all the owning noteable models.
|
||||
*/
|
||||
public function noteable(): MorphTo
|
||||
@@ -84,15 +84,10 @@ class Note extends Model
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function noteableId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,20 +40,21 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\ObjectGroup
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property string $title
|
||||
* @property int $order
|
||||
* @property-read Collection|Account[] $accounts
|
||||
* @property-read int|null $accounts_count
|
||||
* @property-read Collection|Bill[] $bills
|
||||
* @property-read int|null $bills_count
|
||||
* @property-read Collection|PiggyBank[] $piggyBanks
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property string $title
|
||||
* @property int $order
|
||||
* @property Account[]|Collection $accounts
|
||||
* @property null|int $accounts_count
|
||||
* @property Bill[]|Collection $bills
|
||||
* @property null|int $bills_count
|
||||
* @property Collection|PiggyBank[] $piggyBanks
|
||||
* @property null|int $piggy_banks_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static Builder|ObjectGroup newModelQuery()
|
||||
* @method static Builder|ObjectGroup newQuery()
|
||||
* @method static Builder|ObjectGroup query()
|
||||
@@ -64,8 +65,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|ObjectGroup whereTitle($value)
|
||||
* @method static Builder|ObjectGroup whereUpdatedAt($value)
|
||||
* @method static Builder|ObjectGroup whereUserId($value)
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static Builder|ObjectGroup whereUserGroupId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class ObjectGroup extends Model
|
||||
@@ -75,38 +79,35 @@ class ObjectGroup extends Model
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'user_id' => 'integer',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'user_id' => 'integer',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
protected $fillable = ['title', 'order', 'user_id', 'user_group_id'];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return ObjectGroup
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$objectGroupId = (int)$value;
|
||||
/** @var ObjectGroup|null $objectGroup */
|
||||
|
||||
/** @var null|ObjectGroup $objectGroup */
|
||||
$objectGroup = self::where('object_groups.id', $objectGroupId)
|
||||
->where('object_groups.user_id', auth()->user()->id)->first();
|
||||
->where('object_groups.user_id', auth()->user()->id)->first()
|
||||
;
|
||||
if (null !== $objectGroup) {
|
||||
return $objectGroup;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
@@ -136,15 +137,10 @@ class ObjectGroup extends Model
|
||||
return $this->morphedByMany(PiggyBank::class, 'object_groupable');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,32 +40,33 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\PiggyBank
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $account_id
|
||||
* @property string $name
|
||||
* @property string $targetamount
|
||||
* @property Carbon|null $startdate
|
||||
* @property Carbon|null $targetdate
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property-read Account $account
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|ObjectGroup[] $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read Collection|PiggyBankEvent[] $piggyBankEvents
|
||||
* @property-read int|null $piggy_bank_events_count
|
||||
* @property-read Collection|PiggyBankRepetition[] $piggyBankRepetitions
|
||||
* @property-read int|null $piggy_bank_repetitions_count
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $account_id
|
||||
* @property string $name
|
||||
* @property string $targetamount
|
||||
* @property null|Carbon $startdate
|
||||
* @property null|Carbon $targetdate
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property Account $account
|
||||
* @property Attachment[]|Collection $attachments
|
||||
* @property null|int $attachments_count
|
||||
* @property Collection|Note[] $notes
|
||||
* @property null|int $notes_count
|
||||
* @property Collection|ObjectGroup[] $objectGroups
|
||||
* @property null|int $object_groups_count
|
||||
* @property Collection|PiggyBankEvent[] $piggyBankEvents
|
||||
* @property null|int $piggy_bank_events_count
|
||||
* @property Collection|PiggyBankRepetition[] $piggyBankRepetitions
|
||||
* @property null|int $piggy_bank_repetitions_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PiggyBank newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PiggyBank newQuery()
|
||||
* @method static Builder|PiggyBank onlyTrashed()
|
||||
* @method static Builder|PiggyBank onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PiggyBank query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PiggyBank whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PiggyBank whereActive($value)
|
||||
@@ -79,8 +80,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PiggyBank whereTargetamount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PiggyBank whereTargetdate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PiggyBank whereUpdatedAt($value)
|
||||
* @method static Builder|PiggyBank withTrashed()
|
||||
* @method static Builder|PiggyBank withoutTrashed()
|
||||
* @method static Builder|PiggyBank withTrashed()
|
||||
* @method static Builder|PiggyBank withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class PiggyBank extends Model
|
||||
@@ -107,9 +109,6 @@ class PiggyBank extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return PiggyBank
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
@@ -117,26 +116,22 @@ class PiggyBank extends Model
|
||||
if (auth()->check()) {
|
||||
$piggyBankId = (int)$value;
|
||||
$piggyBank = self::where('piggy_banks.id', $piggyBankId)
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
||||
->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*']);
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
||||
->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*'])
|
||||
;
|
||||
if (null !== $piggyBank) {
|
||||
return $piggyBank;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function account(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Account::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
@@ -158,24 +153,17 @@ class PiggyBank extends Model
|
||||
return $this->morphToMany(ObjectGroup::class, 'object_groupable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function piggyBankEvents(): HasMany
|
||||
{
|
||||
return $this->hasMany(PiggyBankEvent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function piggyBankRepetitions(): HasMany
|
||||
{
|
||||
return $this->hasMany(PiggyBankRepetition::class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setTargetamountAttribute($value): void
|
||||
@@ -183,36 +171,27 @@ class PiggyBank extends Model
|
||||
$this->attributes['targetamount'] = (string)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function accountId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function targetamount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,15 +34,16 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
/**
|
||||
* FireflyIII\Models\PiggyBankEvent
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int $piggy_bank_id
|
||||
* @property int|null $transaction_journal_id
|
||||
* @property Carbon $date
|
||||
* @property string $amount
|
||||
* @property PiggyBank $piggyBank
|
||||
* @property-read TransactionJournal|null $transactionJournal
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property int $piggy_bank_id
|
||||
* @property null|int $transaction_journal_id
|
||||
* @property Carbon $date
|
||||
* @property string $amount
|
||||
* @property PiggyBank $piggyBank
|
||||
* @property null|TransactionJournal $transactionJournal
|
||||
*
|
||||
* @method static Builder|PiggyBankEvent newModelQuery()
|
||||
* @method static Builder|PiggyBankEvent newQuery()
|
||||
* @method static Builder|PiggyBankEvent query()
|
||||
@@ -53,6 +54,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @method static Builder|PiggyBankEvent wherePiggyBankId($value)
|
||||
* @method static Builder|PiggyBankEvent whereTransactionJournalId($value)
|
||||
* @method static Builder|PiggyBankEvent whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class PiggyBankEvent extends Model
|
||||
@@ -70,16 +72,12 @@ class PiggyBankEvent extends Model
|
||||
|
||||
protected $hidden = ['amount_encrypted'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function piggyBank(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PiggyBank::class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setAmountAttribute($value): void
|
||||
@@ -87,9 +85,6 @@ class PiggyBankEvent extends Model
|
||||
$this->attributes['amount'] = (string)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionJournal(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class);
|
||||
@@ -97,23 +92,18 @@ class PiggyBankEvent extends Model
|
||||
|
||||
/**
|
||||
* Get the amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function piggyBankId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,14 +34,15 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
/**
|
||||
* FireflyIII\Models\PiggyBankRepetition
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int $piggy_bank_id
|
||||
* @property Carbon|null $startdate
|
||||
* @property Carbon|null $targetdate
|
||||
* @property string $currentamount
|
||||
* @property-read PiggyBank $piggyBank
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property int $piggy_bank_id
|
||||
* @property null|Carbon $startdate
|
||||
* @property null|Carbon $targetdate
|
||||
* @property string $currentamount
|
||||
* @property PiggyBank $piggyBank
|
||||
*
|
||||
* @method static EloquentBuilder|PiggyBankRepetition newModelQuery()
|
||||
* @method static EloquentBuilder|PiggyBankRepetition newQuery()
|
||||
* @method static EloquentBuilder|PiggyBankRepetition onDates(Carbon $start, Carbon $target)
|
||||
@@ -54,6 +55,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @method static EloquentBuilder|PiggyBankRepetition whereStartdate($value)
|
||||
* @method static EloquentBuilder|PiggyBankRepetition whereTargetdate($value)
|
||||
* @method static EloquentBuilder|PiggyBankRepetition whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class PiggyBankRepetition extends Model
|
||||
@@ -70,32 +72,17 @@ class PiggyBankRepetition extends Model
|
||||
|
||||
protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function piggyBank(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PiggyBank::class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $start
|
||||
* @param Carbon $target
|
||||
*
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeOnDates(EloquentBuilder $query, Carbon $start, Carbon $target): EloquentBuilder
|
||||
{
|
||||
return $query->where('startdate', $start->format('Y-m-d'))->where('targetdate', $target->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeRelevantOnDate(EloquentBuilder $query, Carbon $date)
|
||||
@@ -106,16 +93,16 @@ class PiggyBankRepetition extends Model
|
||||
$q->orWhereNull('startdate');
|
||||
}
|
||||
)
|
||||
->where(
|
||||
static function (EloquentBuilder $q) use ($date) {
|
||||
$q->where('targetdate', '>=', $date->format('Y-m-d 00:00:00'));
|
||||
$q->orWhereNull('targetdate');
|
||||
}
|
||||
);
|
||||
->where(
|
||||
static function (EloquentBuilder $q) use ($date) {
|
||||
$q->where('targetdate', '>=', $date->format('Y-m-d 00:00:00'));
|
||||
$q->orWhereNull('targetdate');
|
||||
}
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setCurrentamountAttribute($value): void
|
||||
@@ -125,23 +112,18 @@ class PiggyBankRepetition extends Model
|
||||
|
||||
/**
|
||||
* Get the amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function currentamount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function piggyBankId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +37,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* FireflyIII\Models\Preference
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property int|string|array|null $data
|
||||
* @property-read User $user
|
||||
* @property null|array|int|string $data
|
||||
* @property User $user
|
||||
*
|
||||
* @method static Builder|Preference newModelQuery()
|
||||
* @method static Builder|Preference newQuery()
|
||||
* @method static Builder|Preference query()
|
||||
@@ -52,6 +53,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|Preference whereName($value)
|
||||
* @method static Builder|Preference whereUpdatedAt($value)
|
||||
* @method static Builder|Preference whereUserId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Preference extends Model
|
||||
@@ -66,15 +68,11 @@ class Preference extends Model
|
||||
'data' => 'array',
|
||||
];
|
||||
|
||||
|
||||
protected $fillable = ['user_id', 'data', 'name'];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Preference
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
@@ -82,7 +80,8 @@ class Preference extends Model
|
||||
if (auth()->check()) {
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Preference|null $preference */
|
||||
|
||||
/** @var null|Preference $preference */
|
||||
$preference = $user->preferences()->where('name', $value)->first();
|
||||
if (null === $preference) {
|
||||
$preference = $user->preferences()->where('id', (int)$value)->first();
|
||||
@@ -101,12 +100,10 @@ class Preference extends Model
|
||||
return $preference;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
@@ -41,36 +41,37 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\Recurrence
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $transaction_type_id
|
||||
* @property string $title
|
||||
* @property string $description
|
||||
* @property Carbon|null $first_date
|
||||
* @property Carbon|null $repeat_until
|
||||
* @property Carbon|null $latest_date
|
||||
* @property int|string $repetitions
|
||||
* @property bool $apply_rules
|
||||
* @property bool $active
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|RecurrenceMeta[] $recurrenceMeta
|
||||
* @property-read int|null $recurrence_meta_count
|
||||
* @property-read Collection|RecurrenceRepetition[] $recurrenceRepetitions
|
||||
* @property-read int|null $recurrence_repetitions_count
|
||||
* @property-read Collection|RecurrenceTransaction[] $recurrenceTransactions
|
||||
* @property-read int|null $recurrence_transactions_count
|
||||
* @property-read TransactionCurrency $transactionCurrency
|
||||
* @property-read TransactionType $transactionType
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $transaction_type_id
|
||||
* @property string $title
|
||||
* @property string $description
|
||||
* @property null|Carbon $first_date
|
||||
* @property null|Carbon $repeat_until
|
||||
* @property null|Carbon $latest_date
|
||||
* @property int|string $repetitions
|
||||
* @property bool $apply_rules
|
||||
* @property bool $active
|
||||
* @property Attachment[]|Collection $attachments
|
||||
* @property null|int $attachments_count
|
||||
* @property Collection|Note[] $notes
|
||||
* @property null|int $notes_count
|
||||
* @property Collection|RecurrenceMeta[] $recurrenceMeta
|
||||
* @property null|int $recurrence_meta_count
|
||||
* @property Collection|RecurrenceRepetition[] $recurrenceRepetitions
|
||||
* @property null|int $recurrence_repetitions_count
|
||||
* @property Collection|RecurrenceTransaction[] $recurrenceTransactions
|
||||
* @property null|int $recurrence_transactions_count
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
* @property TransactionType $transactionType
|
||||
* @property User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence newQuery()
|
||||
* @method static Builder|Recurrence onlyTrashed()
|
||||
* @method static Builder|Recurrence onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereApplyRules($value)
|
||||
@@ -86,10 +87,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereTransactionTypeId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereUserId($value)
|
||||
* @method static Builder|Recurrence withTrashed()
|
||||
* @method static Builder|Recurrence withoutTrashed()
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|Recurrence withTrashed()
|
||||
* @method static Builder|Recurrence withoutTrashed()
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereUserGroupId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Recurrence extends Model
|
||||
@@ -98,7 +102,6 @@ class Recurrence extends Model
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -117,43 +120,38 @@ class Recurrence extends Model
|
||||
|
||||
protected $fillable
|
||||
= ['user_id', 'transaction_type_id', 'title', 'description', 'first_date', 'repeat_until', 'latest_date', 'repetitions', 'apply_rules', 'active'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'recurrences';
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Recurrence
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$recurrenceId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Recurrence|null $recurrence */
|
||||
|
||||
/** @var null|Recurrence $recurrence */
|
||||
$recurrence = $user->recurrences()->find($recurrenceId);
|
||||
if (null !== $recurrence) {
|
||||
return $recurrence;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
@@ -167,53 +165,35 @@ class Recurrence extends Model
|
||||
return $this->morphMany(Note::class, 'noteable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function recurrenceMeta(): HasMany
|
||||
{
|
||||
return $this->hasMany(RecurrenceMeta::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function recurrenceRepetitions(): HasMany
|
||||
{
|
||||
return $this->hasMany(RecurrenceRepetition::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function recurrenceTransactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(RecurrenceTransaction::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionTypeId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,17 +35,18 @@ use Illuminate\Database\Query\Builder;
|
||||
/**
|
||||
* FireflyIII\Models\RecurrenceMeta
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $recurrence_id
|
||||
* @property string $name
|
||||
* @property mixed $value
|
||||
* @property-read Recurrence $recurrence
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $recurrence_id
|
||||
* @property string $name
|
||||
* @property mixed $value
|
||||
* @property Recurrence $recurrence
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta newQuery()
|
||||
* @method static Builder|RecurrenceMeta onlyTrashed()
|
||||
* @method static Builder|RecurrenceMeta onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta whereDeletedAt($value)
|
||||
@@ -54,8 +55,9 @@ use Illuminate\Database\Query\Builder;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta whereRecurrenceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta whereValue($value)
|
||||
* @method static Builder|RecurrenceMeta withTrashed()
|
||||
* @method static Builder|RecurrenceMeta withoutTrashed()
|
||||
* @method static Builder|RecurrenceMeta withTrashed()
|
||||
* @method static Builder|RecurrenceMeta withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class RecurrenceMeta extends Model
|
||||
@@ -63,7 +65,6 @@ class RecurrenceMeta extends Model
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -74,24 +75,19 @@ class RecurrenceMeta extends Model
|
||||
];
|
||||
|
||||
protected $fillable = ['recurrence_id', 'name', 'value'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'recurrences_meta';
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function recurrence(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Recurrence::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function recurrenceId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,19 +35,20 @@ use Illuminate\Database\Query\Builder;
|
||||
/**
|
||||
* FireflyIII\Models\RecurrenceRepetition
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $recurrence_id
|
||||
* @property string $repetition_type
|
||||
* @property string $repetition_moment
|
||||
* @property int $repetition_skip
|
||||
* @property int $weekend
|
||||
* @property-read Recurrence $recurrence
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $recurrence_id
|
||||
* @property string $repetition_type
|
||||
* @property string $repetition_moment
|
||||
* @property int $repetition_skip
|
||||
* @property int $weekend
|
||||
* @property Recurrence $recurrence
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newQuery()
|
||||
* @method static Builder|RecurrenceRepetition onlyTrashed()
|
||||
* @method static Builder|RecurrenceRepetition onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition whereDeletedAt($value)
|
||||
@@ -58,8 +59,9 @@ use Illuminate\Database\Query\Builder;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition whereRepetitionType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition whereWeekend($value)
|
||||
* @method static Builder|RecurrenceRepetition withTrashed()
|
||||
* @method static Builder|RecurrenceRepetition withoutTrashed()
|
||||
* @method static Builder|RecurrenceRepetition withTrashed()
|
||||
* @method static Builder|RecurrenceRepetition withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class RecurrenceRepetition extends Model
|
||||
@@ -72,7 +74,6 @@ class RecurrenceRepetition extends Model
|
||||
public const int WEEKEND_TO_FRIDAY = 3;
|
||||
public const int WEEKEND_TO_MONDAY = 4;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -85,44 +86,33 @@ class RecurrenceRepetition extends Model
|
||||
];
|
||||
|
||||
protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'recurrences_repetitions';
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function recurrence(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Recurrence::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function recurrenceId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function repetitionSkip(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function weekend(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,28 +37,29 @@ use Illuminate\Database\Query\Builder;
|
||||
/**
|
||||
* FireflyIII\Models\RecurrenceTransaction
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $recurrence_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property int|string|null $foreign_currency_id
|
||||
* @property int $source_id
|
||||
* @property int $destination_id
|
||||
* @property string $amount
|
||||
* @property string $foreign_amount
|
||||
* @property string $description
|
||||
* @property-read Account $destinationAccount
|
||||
* @property-read TransactionCurrency|null $foreignCurrency
|
||||
* @property-read Recurrence $recurrence
|
||||
* @property-read Collection|RecurrenceTransactionMeta[] $recurrenceTransactionMeta
|
||||
* @property-read int|null $recurrence_transaction_meta_count
|
||||
* @property-read Account $sourceAccount
|
||||
* @property-read TransactionCurrency $transactionCurrency
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $recurrence_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property null|int|string $foreign_currency_id
|
||||
* @property int $source_id
|
||||
* @property int $destination_id
|
||||
* @property string $amount
|
||||
* @property string $foreign_amount
|
||||
* @property string $description
|
||||
* @property Account $destinationAccount
|
||||
* @property null|TransactionCurrency $foreignCurrency
|
||||
* @property Recurrence $recurrence
|
||||
* @property Collection|RecurrenceTransactionMeta[] $recurrenceTransactionMeta
|
||||
* @property null|int $recurrence_transaction_meta_count
|
||||
* @property Account $sourceAccount
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction newQuery()
|
||||
* @method static Builder|RecurrenceTransaction onlyTrashed()
|
||||
* @method static Builder|RecurrenceTransaction onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction whereCreatedAt($value)
|
||||
@@ -72,11 +73,15 @@ use Illuminate\Database\Query\Builder;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction whereSourceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction whereTransactionCurrencyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction whereUpdatedAt($value)
|
||||
* @method static Builder|RecurrenceTransaction withTrashed()
|
||||
* @method static Builder|RecurrenceTransaction withoutTrashed()
|
||||
* @property int|null $transaction_type_id
|
||||
* @method static Builder|RecurrenceTransaction withTrashed()
|
||||
* @method static Builder|RecurrenceTransaction withoutTrashed()
|
||||
*
|
||||
* @property null|int $transaction_type_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction whereTransactionTypeId($value)
|
||||
* @property-read TransactionType|null $transactionType
|
||||
*
|
||||
* @property null|TransactionType $transactionType
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class RecurrenceTransaction extends Model
|
||||
@@ -84,7 +89,6 @@ class RecurrenceTransaction extends Model
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -106,133 +110,91 @@ class RecurrenceTransaction extends Model
|
||||
'foreign_amount',
|
||||
'description',
|
||||
];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'recurrences_transactions';
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function destinationAccount(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Account::class, 'destination_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function foreignCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function recurrence(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Recurrence::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function recurrenceTransactionMeta(): HasMany
|
||||
{
|
||||
return $this->hasMany(RecurrenceTransactionMeta::class, 'rt_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function sourceAccount(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Account::class, 'source_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function destinationId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function foreignAmount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function recurrenceId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function sourceId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function userId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,17 +35,18 @@ use Illuminate\Database\Query\Builder;
|
||||
/**
|
||||
* FireflyIII\Models\RecurrenceTransactionMeta
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $rt_id
|
||||
* @property string $name
|
||||
* @property mixed $value
|
||||
* @property-read RecurrenceTransaction $recurrenceTransaction
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int|string $rt_id
|
||||
* @property string $name
|
||||
* @property mixed $value
|
||||
* @property RecurrenceTransaction $recurrenceTransaction
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta newQuery()
|
||||
* @method static Builder|RecurrenceTransactionMeta onlyTrashed()
|
||||
* @method static Builder|RecurrenceTransactionMeta onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta whereDeletedAt($value)
|
||||
@@ -54,8 +55,9 @@ use Illuminate\Database\Query\Builder;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta whereRtId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta whereValue($value)
|
||||
* @method static Builder|RecurrenceTransactionMeta withTrashed()
|
||||
* @method static Builder|RecurrenceTransactionMeta withoutTrashed()
|
||||
* @method static Builder|RecurrenceTransactionMeta withTrashed()
|
||||
* @method static Builder|RecurrenceTransactionMeta withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class RecurrenceTransactionMeta extends Model
|
||||
@@ -63,7 +65,6 @@ class RecurrenceTransactionMeta extends Model
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -74,24 +75,19 @@ class RecurrenceTransactionMeta extends Model
|
||||
];
|
||||
|
||||
protected $fillable = ['rt_id', 'name', 'value'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'rt_meta';
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function recurrenceTransaction(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RecurrenceTransaction::class, 'rt_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function rtId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,15 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
/**
|
||||
* FireflyIII\Models\Role
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string $name
|
||||
* @property string|null $display_name
|
||||
* @property string|null $description
|
||||
* @property-read Collection|User[] $users
|
||||
* @property-read int|null $users_count
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property string $name
|
||||
* @property null|string $display_name
|
||||
* @property null|string $description
|
||||
* @property Collection|User[] $users
|
||||
* @property null|int $users_count
|
||||
*
|
||||
* @method static Builder|Role newModelQuery()
|
||||
* @method static Builder|Role newQuery()
|
||||
* @method static Builder|Role query()
|
||||
@@ -52,6 +53,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
* @method static Builder|Role whereId($value)
|
||||
* @method static Builder|Role whereName($value)
|
||||
* @method static Builder|Role whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Role extends Model
|
||||
@@ -64,12 +66,8 @@ class Role extends Model
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
|
||||
protected $fillable = ['name', 'display_name', 'description'];
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class);
|
||||
|
||||
@@ -40,28 +40,29 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\Rule
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $rule_group_id
|
||||
* @property string $title
|
||||
* @property string|null $description
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property bool $strict
|
||||
* @property-read string $action_value
|
||||
* @property-read Collection|RuleAction[] $ruleActions
|
||||
* @property-read int|null $rule_actions_count
|
||||
* @property-read RuleGroup $ruleGroup
|
||||
* @property Collection|RuleTrigger[] $ruleTriggers
|
||||
* @property-read int|null $rule_triggers_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $rule_group_id
|
||||
* @property string $title
|
||||
* @property null|string $description
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property bool $strict
|
||||
* @property string $action_value
|
||||
* @property Collection|RuleAction[] $ruleActions
|
||||
* @property null|int $rule_actions_count
|
||||
* @property RuleGroup $ruleGroup
|
||||
* @property Collection|RuleTrigger[] $ruleTriggers
|
||||
* @property null|int $rule_triggers_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule newQuery()
|
||||
* @method static Builder|Rule onlyTrashed()
|
||||
* @method static Builder|Rule onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereCreatedAt($value)
|
||||
@@ -75,11 +76,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereUserId($value)
|
||||
* @method static Builder|Rule withTrashed()
|
||||
* @method static Builder|Rule withoutTrashed()
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|Rule withTrashed()
|
||||
* @method static Builder|Rule withoutTrashed()
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereUserGroupId($value)
|
||||
* @property-read UserGroup|null $userGroup
|
||||
*
|
||||
* @property null|UserGroup $userGroup
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Rule extends Model
|
||||
@@ -88,7 +93,6 @@ class Rule extends Model
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -106,53 +110,41 @@ class Rule extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Rule
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$ruleId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Rule|null $rule */
|
||||
|
||||
/** @var null|Rule $rule */
|
||||
$rule = $user->rules()->find($ruleId);
|
||||
if (null !== $rule) {
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function ruleActions(): HasMany
|
||||
{
|
||||
return $this->hasMany(RuleAction::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function ruleGroup(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RuleGroup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function ruleTriggers(): HasMany
|
||||
{
|
||||
return $this->hasMany(RuleTrigger::class);
|
||||
@@ -160,39 +152,28 @@ class Rule extends Model
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
|
||||
*/
|
||||
public function setDescriptionAttribute($value): void
|
||||
{
|
||||
$this->attributes['description'] = e($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function userGroup(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(UserGroup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function ruleGroupId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +35,16 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* FireflyIII\Models\RuleAction
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property int $rule_id
|
||||
* @property string|null $action_type
|
||||
* @property string|null $action_value
|
||||
* @property null|string $action_type
|
||||
* @property null|string $action_value
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property-read Rule $rule
|
||||
* @property Rule $rule
|
||||
*
|
||||
* @method static Builder|RuleAction newModelQuery()
|
||||
* @method static Builder|RuleAction newQuery()
|
||||
* @method static Builder|RuleAction query()
|
||||
@@ -56,6 +57,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @method static Builder|RuleAction whereRuleId($value)
|
||||
* @method static Builder|RuleAction whereStopProcessing($value)
|
||||
* @method static Builder|RuleAction whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class RuleAction extends Model
|
||||
@@ -71,35 +73,24 @@ class RuleAction extends Model
|
||||
'stop_processing' => 'boolean',
|
||||
];
|
||||
|
||||
|
||||
protected $fillable = ['rule_id', 'action_type', 'action_value', 'order', 'active', 'stop_processing'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function rule(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Rule::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function ruleId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,21 +41,22 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* FireflyIII\Models\RuleGroup
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property string|null $title
|
||||
* @property string|null $description
|
||||
* @property null|string $title
|
||||
* @property null|string $description
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property Collection|Rule[] $rules
|
||||
* @property-read int|null $rules_count
|
||||
* @property-read User $user
|
||||
* @property null|int $rules_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newQuery()
|
||||
* @method static Builder|RuleGroup onlyTrashed()
|
||||
* @method static Builder|RuleGroup onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereCreatedAt($value)
|
||||
@@ -67,10 +68,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserId($value)
|
||||
* @method static Builder|RuleGroup withTrashed()
|
||||
* @method static Builder|RuleGroup withoutTrashed()
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|RuleGroup withTrashed()
|
||||
* @method static Builder|RuleGroup withoutTrashed()
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserGroupId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class RuleGroup extends Model
|
||||
@@ -79,7 +83,6 @@ class RuleGroup extends Model
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -90,55 +93,45 @@ class RuleGroup extends Model
|
||||
'order' => 'int',
|
||||
];
|
||||
|
||||
|
||||
protected $fillable = ['user_id', 'user_group_id', 'stop_processing', 'order', 'title', 'description', 'active'];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return RuleGroup
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$ruleGroupId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var RuleGroup|null $ruleGroup */
|
||||
|
||||
/** @var null|RuleGroup $ruleGroup */
|
||||
$ruleGroup = $user->ruleGroups()->find($ruleGroupId);
|
||||
if (null !== $ruleGroup) {
|
||||
return $ruleGroup;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function rules(): HasMany
|
||||
{
|
||||
return $this->hasMany(Rule::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +35,16 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* FireflyIII\Models\RuleTrigger
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property int $rule_id
|
||||
* @property string|null $trigger_type
|
||||
* @property string|null $trigger_value
|
||||
* @property null|string $trigger_type
|
||||
* @property null|string $trigger_value
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property-read Rule $rule
|
||||
* @property Rule $rule
|
||||
*
|
||||
* @method static Builder|RuleTrigger newModelQuery()
|
||||
* @method static Builder|RuleTrigger newQuery()
|
||||
* @method static Builder|RuleTrigger query()
|
||||
@@ -56,6 +57,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @method static Builder|RuleTrigger whereTriggerType($value)
|
||||
* @method static Builder|RuleTrigger whereTriggerValue($value)
|
||||
* @method static Builder|RuleTrigger whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class RuleTrigger extends Model
|
||||
@@ -71,35 +73,24 @@ class RuleTrigger extends Model
|
||||
'stop_processing' => 'boolean',
|
||||
];
|
||||
|
||||
|
||||
protected $fillable = ['rule_id', 'trigger_type', 'trigger_value', 'order', 'active', 'stop_processing'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function rule(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Rule::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function ruleId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,28 +40,29 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\Tag
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property string $tag
|
||||
* @property string $tagMode
|
||||
* @property Carbon|null $date
|
||||
* @property string|null $description
|
||||
* @property float|null $latitude
|
||||
* @property float|null $longitude
|
||||
* @property int|null $zoomLevel
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property-read Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property string $tag
|
||||
* @property string $tagMode
|
||||
* @property null|Carbon $date
|
||||
* @property null|string $description
|
||||
* @property null|float $latitude
|
||||
* @property null|float $longitude
|
||||
* @property null|int $zoomLevel
|
||||
* @property Attachment[]|Collection $attachments
|
||||
* @property null|int $attachments_count
|
||||
* @property Collection|Location[] $locations
|
||||
* @property null|int $locations_count
|
||||
* @property Collection|TransactionJournal[] $transactionJournals
|
||||
* @property null|int $transaction_journals_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag newQuery()
|
||||
* @method static Builder|Tag onlyTrashed()
|
||||
* @method static Builder|Tag onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereDate($value)
|
||||
@@ -75,10 +76,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereZoomLevel($value)
|
||||
* @method static Builder|Tag withTrashed()
|
||||
* @method static Builder|Tag withoutTrashed()
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|Tag withTrashed()
|
||||
* @method static Builder|Tag withoutTrashed()
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereUserGroupId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Tag extends Model
|
||||
@@ -87,7 +91,6 @@ class Tag extends Model
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -106,53 +109,41 @@ class Tag extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Tag
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$tagId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Tag|null $tag */
|
||||
|
||||
/** @var null|Tag $tag */
|
||||
$tag = $user->tags()->find($tagId);
|
||||
if (null !== $tag) {
|
||||
return $tag;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function locations(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Location::class, 'locatable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function transactionJournals(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(TransactionJournal::class);
|
||||
|
||||
@@ -38,54 +38,57 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
/**
|
||||
* FireflyIII\Models\Transaction
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property bool $reconciled
|
||||
* @property int $account_id
|
||||
* @property int $transaction_journal_id
|
||||
* @property string|null $description
|
||||
* @property int|null $transaction_currency_id
|
||||
* @property string|int|null $modified
|
||||
* @property string|int|null $modified_foreign
|
||||
* @property string $date
|
||||
* @property string $max_date
|
||||
* @property string $amount
|
||||
* @property string|null $foreign_amount
|
||||
* @property int|null $foreign_currency_id
|
||||
* @property int $identifier
|
||||
* @property-read Account $account
|
||||
* @property-read Collection|Budget[] $budgets
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read Collection|Category[] $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read TransactionCurrency|null $foreignCurrency
|
||||
* @property-read TransactionCurrency|null $transactionCurrency
|
||||
* @property-read TransactionJournal $transactionJournal
|
||||
* @method static Builder|Transaction after(Carbon $date)
|
||||
* @method static Builder|Transaction before(Carbon $date)
|
||||
* @method static Builder|Transaction newModelQuery()
|
||||
* @method static Builder|Transaction newQuery()
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property bool $reconciled
|
||||
* @property int $account_id
|
||||
* @property int $transaction_journal_id
|
||||
* @property null|string $description
|
||||
* @property null|int $transaction_currency_id
|
||||
* @property null|int|string $modified
|
||||
* @property null|int|string $modified_foreign
|
||||
* @property string $date
|
||||
* @property string $max_date
|
||||
* @property string $amount
|
||||
* @property null|string $foreign_amount
|
||||
* @property null|int $foreign_currency_id
|
||||
* @property int $identifier
|
||||
* @property Account $account
|
||||
* @property Budget[]|Collection $budgets
|
||||
* @property null|int $budgets_count
|
||||
* @property Category[]|Collection $categories
|
||||
* @property null|int $categories_count
|
||||
* @property null|TransactionCurrency $foreignCurrency
|
||||
* @property null|TransactionCurrency $transactionCurrency
|
||||
* @property TransactionJournal $transactionJournal
|
||||
*
|
||||
* @method static Builder|Transaction after(Carbon $date)
|
||||
* @method static Builder|Transaction before(Carbon $date)
|
||||
* @method static Builder|Transaction newModelQuery()
|
||||
* @method static Builder|Transaction newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction onlyTrashed()
|
||||
* @method static Builder|Transaction query()
|
||||
* @method static Builder|Transaction transactionTypes($types)
|
||||
* @method static Builder|Transaction whereAccountId($value)
|
||||
* @method static Builder|Transaction whereAmount($value)
|
||||
* @method static Builder|Transaction whereCreatedAt($value)
|
||||
* @method static Builder|Transaction whereDeletedAt($value)
|
||||
* @method static Builder|Transaction whereDescription($value)
|
||||
* @method static Builder|Transaction whereForeignAmount($value)
|
||||
* @method static Builder|Transaction whereForeignCurrencyId($value)
|
||||
* @method static Builder|Transaction whereId($value)
|
||||
* @method static Builder|Transaction whereIdentifier($value)
|
||||
* @method static Builder|Transaction whereReconciled($value)
|
||||
* @method static Builder|Transaction whereTransactionCurrencyId($value)
|
||||
* @method static Builder|Transaction whereTransactionJournalId($value)
|
||||
* @method static Builder|Transaction whereUpdatedAt($value)
|
||||
* @method static Builder|Transaction query()
|
||||
* @method static Builder|Transaction transactionTypes($types)
|
||||
* @method static Builder|Transaction whereAccountId($value)
|
||||
* @method static Builder|Transaction whereAmount($value)
|
||||
* @method static Builder|Transaction whereCreatedAt($value)
|
||||
* @method static Builder|Transaction whereDeletedAt($value)
|
||||
* @method static Builder|Transaction whereDescription($value)
|
||||
* @method static Builder|Transaction whereForeignAmount($value)
|
||||
* @method static Builder|Transaction whereForeignCurrencyId($value)
|
||||
* @method static Builder|Transaction whereId($value)
|
||||
* @method static Builder|Transaction whereIdentifier($value)
|
||||
* @method static Builder|Transaction whereReconciled($value)
|
||||
* @method static Builder|Transaction whereTransactionCurrencyId($value)
|
||||
* @method static Builder|Transaction whereTransactionJournalId($value)
|
||||
* @method static Builder|Transaction whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed()
|
||||
* @property int|string $the_count
|
||||
*
|
||||
* @property int|string $the_count
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Transaction extends Model
|
||||
@@ -94,7 +97,6 @@ class Transaction extends Model
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -123,8 +125,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Get the account this object belongs to.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function account(): BelongsTo
|
||||
{
|
||||
@@ -133,8 +133,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Get the budget(s) this object belongs to.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function budgets(): BelongsToMany
|
||||
{
|
||||
@@ -143,8 +141,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Get the category(ies) this object belongs to.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function categories(): BelongsToMany
|
||||
{
|
||||
@@ -153,8 +149,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Get the currency this object belongs to.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function foreignCurrency(): BelongsTo
|
||||
{
|
||||
@@ -163,10 +157,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Check for transactions AFTER a specified date.
|
||||
*
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeAfter(Builder $query, Carbon $date): void
|
||||
{
|
||||
@@ -178,11 +168,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Check if a table is joined.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $table
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isJoined(Builder $query, string $table): bool
|
||||
{
|
||||
@@ -199,10 +184,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Check for transactions BEFORE the specified date.
|
||||
*
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeBefore(Builder $query, Carbon $date): void
|
||||
{
|
||||
@@ -212,11 +193,6 @@ class Transaction extends Model
|
||||
$query->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeTransactionTypes(Builder $query, array $types): void
|
||||
{
|
||||
if (!self::isJoined($query, 'transaction_journals')) {
|
||||
@@ -230,7 +206,6 @@ class Transaction extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setAmountAttribute($value): void
|
||||
@@ -238,63 +213,47 @@ class Transaction extends Model
|
||||
$this->attributes['amount'] = (string)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionJournal(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function accountId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the foreign amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function foreignAmount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionJournalId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,26 +39,27 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionCurrency
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property bool $enabled
|
||||
* @property bool|null $userGroupDefault
|
||||
* @property bool|null $userGroupEnabled
|
||||
* @property string $code
|
||||
* @property string $name
|
||||
* @property string $symbol
|
||||
* @property int $decimal_places
|
||||
* @property-read Collection|BudgetLimit[] $budgetLimits
|
||||
* @property-read int|null $budget_limits_count
|
||||
* @property-read Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property bool $enabled
|
||||
* @property null|bool $userGroupDefault
|
||||
* @property null|bool $userGroupEnabled
|
||||
* @property string $code
|
||||
* @property string $name
|
||||
* @property string $symbol
|
||||
* @property int $decimal_places
|
||||
* @property BudgetLimit[]|Collection $budgetLimits
|
||||
* @property null|int $budget_limits_count
|
||||
* @property Collection|TransactionJournal[] $transactionJournals
|
||||
* @property null|int $transaction_journals_count
|
||||
* @property Collection|Transaction[] $transactions
|
||||
* @property null|int $transactions_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newQuery()
|
||||
* @method static Builder|TransactionCurrency onlyTrashed()
|
||||
* @method static Builder|TransactionCurrency onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency whereCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency whereCreatedAt($value)
|
||||
@@ -69,12 +70,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency whereSymbol($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency whereUpdatedAt($value)
|
||||
* @method static Builder|TransactionCurrency withTrashed()
|
||||
* @method static Builder|TransactionCurrency withoutTrashed()
|
||||
* @property-read Collection<int, UserGroup> $userGroups
|
||||
* @property-read int|null $user_groups_count
|
||||
* @property-read Collection<int, User> $users
|
||||
* @property-read int|null $users_count
|
||||
* @method static Builder|TransactionCurrency withTrashed()
|
||||
* @method static Builder|TransactionCurrency withoutTrashed()
|
||||
*
|
||||
* @property Collection<int, UserGroup> $userGroups
|
||||
* @property null|int $user_groups_count
|
||||
* @property Collection<int, User> $users
|
||||
* @property null|int $users_count
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class TransactionCurrency extends Model
|
||||
@@ -98,9 +101,6 @@ class TransactionCurrency extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
@@ -110,17 +110,14 @@ class TransactionCurrency extends Model
|
||||
$currency = self::find($currencyId);
|
||||
if (null !== $currency) {
|
||||
$currency->refreshForUser(auth()->user());
|
||||
|
||||
return $currency;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function refreshForUser(User $user)
|
||||
{
|
||||
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
|
||||
@@ -129,25 +126,16 @@ class TransactionCurrency extends Model
|
||||
$this->userGroupEnabled = null !== $current;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function budgetLimits(): HasMany
|
||||
{
|
||||
return $this->hasMany(BudgetLimit::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactionJournals(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Transaction::class);
|
||||
@@ -155,8 +143,6 @@ class TransactionCurrency extends Model
|
||||
|
||||
/**
|
||||
* Link to user groups
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function userGroups(): BelongsToMany
|
||||
{
|
||||
@@ -165,21 +151,16 @@ class TransactionCurrency extends Model
|
||||
|
||||
/**
|
||||
* Link to users
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class)->withTimestamps()->withPivot('user_default');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function decimalPlaces(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,18 +39,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionGroup
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property string|null $title
|
||||
* @property-read Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property null|string $title
|
||||
* @property Collection|TransactionJournal[] $transactionJournals
|
||||
* @property null|int $transaction_journals_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup newQuery()
|
||||
* @method static Builder|TransactionGroup onlyTrashed()
|
||||
* @method static Builder|TransactionGroup onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereDeletedAt($value)
|
||||
@@ -58,11 +59,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereUserId($value)
|
||||
* @method static Builder|TransactionGroup withTrashed()
|
||||
* @method static Builder|TransactionGroup withoutTrashed()
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|TransactionGroup withTrashed()
|
||||
* @method static Builder|TransactionGroup withoutTrashed()
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereUserGroupId($value)
|
||||
* @property-read UserGroup|null $userGroup
|
||||
*
|
||||
* @property null|UserGroup $userGroup
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class TransactionGroup extends Model
|
||||
@@ -71,7 +76,6 @@ class TransactionGroup extends Model
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'id' => 'integer',
|
||||
@@ -82,15 +86,11 @@ class TransactionGroup extends Model
|
||||
'date' => 'datetime',
|
||||
];
|
||||
|
||||
|
||||
protected $fillable = ['user_id', 'user_group_id', 'title'];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return TransactionGroup
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
@@ -98,15 +98,19 @@ class TransactionGroup extends Model
|
||||
app('log')->debug(sprintf('Now in %s("%s")', __METHOD__, $value));
|
||||
if (auth()->check()) {
|
||||
$groupId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
app('log')->debug(sprintf('User authenticated as %s', $user->email));
|
||||
/** @var TransactionGroup|null $group */
|
||||
|
||||
/** @var null|TransactionGroup $group */
|
||||
$group = $user->transactionGroups()
|
||||
->with(['transactionJournals', 'transactionJournals.transactions'])
|
||||
->where('transaction_groups.id', $groupId)->first(['transaction_groups.*']);
|
||||
->with(['transactionJournals', 'transactionJournals.transactions'])
|
||||
->where('transaction_groups.id', $groupId)->first(['transaction_groups.*'])
|
||||
;
|
||||
if (null !== $group) {
|
||||
app('log')->debug(sprintf('Found group #%d.', $group->id));
|
||||
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
@@ -115,25 +119,16 @@ class TransactionGroup extends Model
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactionJournals(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function userGroup(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(UserGroup::class);
|
||||
|
||||
@@ -44,84 +44,89 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionJournal
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $transaction_type_id
|
||||
* @property int|string|null $transaction_group_id
|
||||
* @property int|string|null $bill_id
|
||||
* @property int|string|null $transaction_currency_id
|
||||
* @property string|null $description
|
||||
* @property Carbon $date
|
||||
* @property Carbon|null $interest_date
|
||||
* @property Carbon|null $book_date
|
||||
* @property Carbon|null $process_date
|
||||
* @property int $order
|
||||
* @property int $tag_count
|
||||
* @property string $transaction_type_type
|
||||
* @property bool $encrypted
|
||||
* @property bool $completed
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Bill|null $bill
|
||||
* @property-read Collection|Budget[] $budgets
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read Collection|Category[] $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read Collection|TransactionJournalLink[] $destJournalLinks
|
||||
* @property-read int|null $dest_journal_links_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|PiggyBankEvent[] $piggyBankEvents
|
||||
* @property-read int|null $piggy_bank_events_count
|
||||
* @property-read Collection|TransactionJournalLink[] $sourceJournalLinks
|
||||
* @property-read int|null $source_journal_links_count
|
||||
* @property-read Collection|Tag[] $tags
|
||||
* @property-read int|null $tags_count
|
||||
* @property-read TransactionCurrency|null $transactionCurrency
|
||||
* @property-read TransactionGroup|null $transactionGroup
|
||||
* @property-read Collection|TransactionJournalMeta[] $transactionJournalMeta
|
||||
* @property-read int|null $transaction_journal_meta_count
|
||||
* @property-read TransactionType $transactionType
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read User $user
|
||||
* @method static EloquentBuilder|TransactionJournal after(Carbon $date)
|
||||
* @method static EloquentBuilder|TransactionJournal before(Carbon $date)
|
||||
* @method static EloquentBuilder|TransactionJournal newModelQuery()
|
||||
* @method static EloquentBuilder|TransactionJournal newQuery()
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $transaction_type_id
|
||||
* @property null|int|string $transaction_group_id
|
||||
* @property null|int|string $bill_id
|
||||
* @property null|int|string $transaction_currency_id
|
||||
* @property null|string $description
|
||||
* @property Carbon $date
|
||||
* @property null|Carbon $interest_date
|
||||
* @property null|Carbon $book_date
|
||||
* @property null|Carbon $process_date
|
||||
* @property int $order
|
||||
* @property int $tag_count
|
||||
* @property string $transaction_type_type
|
||||
* @property bool $encrypted
|
||||
* @property bool $completed
|
||||
* @property Attachment[]|Collection $attachments
|
||||
* @property null|int $attachments_count
|
||||
* @property null|Bill $bill
|
||||
* @property Budget[]|Collection $budgets
|
||||
* @property null|int $budgets_count
|
||||
* @property Category[]|Collection $categories
|
||||
* @property null|int $categories_count
|
||||
* @property Collection|TransactionJournalLink[] $destJournalLinks
|
||||
* @property null|int $dest_journal_links_count
|
||||
* @property Collection|Note[] $notes
|
||||
* @property null|int $notes_count
|
||||
* @property Collection|PiggyBankEvent[] $piggyBankEvents
|
||||
* @property null|int $piggy_bank_events_count
|
||||
* @property Collection|TransactionJournalLink[] $sourceJournalLinks
|
||||
* @property null|int $source_journal_links_count
|
||||
* @property Collection|Tag[] $tags
|
||||
* @property null|int $tags_count
|
||||
* @property null|TransactionCurrency $transactionCurrency
|
||||
* @property null|TransactionGroup $transactionGroup
|
||||
* @property Collection|TransactionJournalMeta[] $transactionJournalMeta
|
||||
* @property null|int $transaction_journal_meta_count
|
||||
* @property TransactionType $transactionType
|
||||
* @property Collection|Transaction[] $transactions
|
||||
* @property null|int $transactions_count
|
||||
* @property User $user
|
||||
*
|
||||
* @method static EloquentBuilder|TransactionJournal after(Carbon $date)
|
||||
* @method static EloquentBuilder|TransactionJournal before(Carbon $date)
|
||||
* @method static EloquentBuilder|TransactionJournal newModelQuery()
|
||||
* @method static EloquentBuilder|TransactionJournal newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|TransactionJournal onlyTrashed()
|
||||
* @method static EloquentBuilder|TransactionJournal query()
|
||||
* @method static EloquentBuilder|TransactionJournal transactionTypes($types)
|
||||
* @method static EloquentBuilder|TransactionJournal whereBillId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereBookDate($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereCompleted($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereCreatedAt($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereDate($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereDeletedAt($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereDescription($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereEncrypted($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereInterestDate($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereOrder($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereProcessDate($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereTagCount($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereTransactionCurrencyId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereTransactionGroupId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereTransactionTypeId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereUpdatedAt($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereUserId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal query()
|
||||
* @method static EloquentBuilder|TransactionJournal transactionTypes($types)
|
||||
* @method static EloquentBuilder|TransactionJournal whereBillId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereBookDate($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereCompleted($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereCreatedAt($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereDate($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereDeletedAt($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereDescription($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereEncrypted($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereInterestDate($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereOrder($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereProcessDate($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereTagCount($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereTransactionCurrencyId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereTransactionGroupId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereTransactionTypeId($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereUpdatedAt($value)
|
||||
* @method static EloquentBuilder|TransactionJournal whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property int|string $the_count
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @property Collection|Location[] $locations
|
||||
* @property null|int $locations_count
|
||||
* @property int|string $the_count
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static EloquentBuilder|TransactionJournal whereUserGroupId($value)
|
||||
* @property-read Collection<int, AuditLogEntry> $auditLogEntries
|
||||
* @property-read int|null $audit_log_entries_count
|
||||
*
|
||||
* @property Collection<int, AuditLogEntry> $auditLogEntries
|
||||
* @property null|int $audit_log_entries_count
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
@@ -131,7 +136,6 @@ class TransactionJournal extends Model
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -147,7 +151,6 @@ class TransactionJournal extends Model
|
||||
'completed' => 'boolean',
|
||||
];
|
||||
|
||||
|
||||
protected $fillable
|
||||
= [
|
||||
'user_id',
|
||||
@@ -167,18 +170,17 @@ class TransactionJournal extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return TransactionJournal
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$journalId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var TransactionJournal|null $journal */
|
||||
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = $user->transactionJournals()->where('transaction_journals.id', $journalId)->first(['transaction_journals.*']);
|
||||
if (null !== $journal) {
|
||||
return $journal;
|
||||
@@ -188,65 +190,41 @@ class TransactionJournal extends Model
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function auditLogEntries(): MorphMany
|
||||
{
|
||||
return $this->morphMany(AuditLogEntry::class, 'auditable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function bill(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Bill::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function budgets(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Budget::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function categories(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Category::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function destJournalLinks(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournalLink::class, 'destination_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isTransfer(): bool
|
||||
{
|
||||
if (null !== $this->transaction_type_type) {
|
||||
@@ -256,9 +234,6 @@ class TransactionJournal extends Model
|
||||
return $this->transactionType->isTransfer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function locations(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Location::class, 'locatable');
|
||||
@@ -272,43 +247,21 @@ class TransactionJournal extends Model
|
||||
return $this->morphMany(Note::class, 'noteable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function piggyBankEvents(): HasMany
|
||||
{
|
||||
return $this->hasMany(PiggyBankEvent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeAfter(EloquentBuilder $query, Carbon $date): EloquentBuilder
|
||||
{
|
||||
return $query->where('transaction_journals.date', '>=', $date->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeBefore(EloquentBuilder $query, Carbon $date): EloquentBuilder
|
||||
{
|
||||
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeTransactionTypes(EloquentBuilder $query, array $types): void
|
||||
{
|
||||
if (!self::isJoined($query, 'transaction_types')) {
|
||||
@@ -321,12 +274,6 @@ class TransactionJournal extends Model
|
||||
|
||||
/**
|
||||
* Checks if tables are joined.
|
||||
*
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $table
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isJoined(Builder $query, string $table): bool
|
||||
{
|
||||
@@ -340,79 +287,52 @@ class TransactionJournal extends Model
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function sourceJournalLinks(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournalLink::class, 'source_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function tags(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tag::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionGroup(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionGroup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactionJournalMeta(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournalMeta::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Transaction::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionTypeId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,20 +37,21 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionJournalLink
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int $link_type_id
|
||||
* @property int $source_id
|
||||
* @property int $destination_id
|
||||
* @property string|null $comment
|
||||
* @property-read TransactionJournal $destination
|
||||
* @property-read LinkType $linkType
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read TransactionJournal $source
|
||||
* @property-read string $inward
|
||||
* @property-read string $outward
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property int $link_type_id
|
||||
* @property int $source_id
|
||||
* @property int $destination_id
|
||||
* @property null|string $comment
|
||||
* @property TransactionJournal $destination
|
||||
* @property LinkType $linkType
|
||||
* @property Collection|Note[] $notes
|
||||
* @property null|int $notes_count
|
||||
* @property TransactionJournal $source
|
||||
* @property string $inward
|
||||
* @property string $outward
|
||||
*
|
||||
* @method static Builder|TransactionJournalLink newModelQuery()
|
||||
* @method static Builder|TransactionJournalLink newQuery()
|
||||
* @method static Builder|TransactionJournalLink query()
|
||||
@@ -61,6 +62,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|TransactionJournalLink whereLinkTypeId($value)
|
||||
* @method static Builder|TransactionJournalLink whereSourceId($value)
|
||||
* @method static Builder|TransactionJournalLink whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class TransactionJournalLink extends Model
|
||||
@@ -72,16 +74,13 @@ class TransactionJournalLink extends Model
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'journal_links';
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return TransactionJournalLink
|
||||
*
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
@@ -89,29 +88,25 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function destination(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class, 'destination_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function linkType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(LinkType::class);
|
||||
@@ -125,41 +120,29 @@ class TransactionJournalLink extends Model
|
||||
return $this->morphMany(Note::class, 'noteable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function source(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class, 'source_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function destinationId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function linkTypeId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function sourceId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,18 +35,19 @@ use Illuminate\Database\Query\Builder;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionJournalMeta
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int $transaction_journal_id
|
||||
* @property string $name
|
||||
* @property mixed $data
|
||||
* @property string $hash
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property-read TransactionJournal $transactionJournal
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property int $transaction_journal_id
|
||||
* @property string $name
|
||||
* @property mixed $data
|
||||
* @property string $hash
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property TransactionJournal $transactionJournal
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta newQuery()
|
||||
* @method static Builder|TransactionJournalMeta onlyTrashed()
|
||||
* @method static Builder|TransactionJournalMeta onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta whereData($value)
|
||||
@@ -56,8 +57,9 @@ use Illuminate\Database\Query\Builder;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta whereTransactionJournalId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta whereUpdatedAt($value)
|
||||
* @method static Builder|TransactionJournalMeta withTrashed()
|
||||
* @method static Builder|TransactionJournalMeta withoutTrashed()
|
||||
* @method static Builder|TransactionJournalMeta withTrashed()
|
||||
* @method static Builder|TransactionJournalMeta withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class TransactionJournalMeta extends Model
|
||||
@@ -65,7 +67,6 @@ class TransactionJournalMeta extends Model
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -74,11 +75,11 @@ class TransactionJournalMeta extends Model
|
||||
];
|
||||
|
||||
protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'journal_meta';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed
|
||||
@@ -89,7 +90,6 @@ class TransactionJournalMeta extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setDataAttribute($value): void
|
||||
@@ -99,21 +99,15 @@ class TransactionJournalMeta extends Model
|
||||
$this->attributes['hash'] = hash('sha256', (string)$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionJournal(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionJournalId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,24 +36,26 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionType
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property string $type
|
||||
* @property-read Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property string $type
|
||||
* @property Collection|TransactionJournal[] $transactionJournals
|
||||
* @property null|int $transaction_journals_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionType newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionType newQuery()
|
||||
* @method static Builder|TransactionType onlyTrashed()
|
||||
* @method static Builder|TransactionType onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionType query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionType whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionType whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionType whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionType whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionType whereUpdatedAt($value)
|
||||
* @method static Builder|TransactionType withTrashed()
|
||||
* @method static Builder|TransactionType withoutTrashed()
|
||||
* @method static Builder|TransactionType withTrashed()
|
||||
* @method static Builder|TransactionType withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class TransactionType extends Model
|
||||
@@ -71,18 +73,15 @@ class TransactionType extends Model
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
protected $fillable = ['type'];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return TransactionType
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $type): self
|
||||
@@ -94,44 +93,30 @@ class TransactionType extends Model
|
||||
if (null !== $transactionType) {
|
||||
return $transactionType;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDeposit(): bool
|
||||
{
|
||||
return self::DEPOSIT === $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isOpeningBalance(): bool
|
||||
{
|
||||
return self::OPENING_BALANCE === $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isTransfer(): bool
|
||||
{
|
||||
return self::TRANSFER === $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isWithdrawal(): bool
|
||||
{
|
||||
return self::WITHDRAWAL === $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactionJournals(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournal::class);
|
||||
|
||||
@@ -40,13 +40,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class UserGroup
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property string $title
|
||||
* @property-read Collection|GroupMembership[] $groupMemberships
|
||||
* @property-read int|null $group_memberships_count
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|string $deleted_at
|
||||
* @property string $title
|
||||
* @property Collection|GroupMembership[] $groupMemberships
|
||||
* @property null|int $group_memberships_count
|
||||
*
|
||||
* @method static Builder|UserGroup newModelQuery()
|
||||
* @method static Builder|UserGroup newQuery()
|
||||
* @method static Builder|UserGroup query()
|
||||
@@ -55,40 +56,42 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|UserGroup whereId($value)
|
||||
* @method static Builder|UserGroup whereTitle($value)
|
||||
* @method static Builder|UserGroup whereUpdatedAt($value)
|
||||
* @property-read Collection<int, Account> $accounts
|
||||
* @property-read int|null $accounts_count
|
||||
* @property-read Collection<int, AvailableBudget> $availableBudgets
|
||||
* @property-read int|null $available_budgets_count
|
||||
* @property-read Collection<int, Bill> $bills
|
||||
* @property-read int|null $bills_count
|
||||
* @property-read Collection<int, Budget> $budgets
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read Collection<int, PiggyBank> $piggyBanks
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read Collection<int, TransactionJournal> $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read Collection<int, Attachment> $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection<int, Category> $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read Collection<int, CurrencyExchangeRate> $currencyExchangeRates
|
||||
* @property-read int|null $currency_exchange_rates_count
|
||||
* @property-read Collection<int, ObjectGroup> $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read Collection<int, Recurrence> $recurrences
|
||||
* @property-read int|null $recurrences_count
|
||||
* @property-read Collection<int, RuleGroup> $ruleGroups
|
||||
* @property-read int|null $rule_groups_count
|
||||
* @property-read Collection<int, Rule> $rules
|
||||
* @property-read int|null $rules_count
|
||||
* @property-read Collection<int, Tag> $tags
|
||||
* @property-read int|null $tags_count
|
||||
* @property-read Collection<int, TransactionGroup> $transactionGroups
|
||||
* @property-read int|null $transaction_groups_count
|
||||
* @property-read Collection<int, Webhook> $webhooks
|
||||
* @property-read int|null $webhooks_count
|
||||
* @property-read Collection<int, TransactionCurrency> $currencies
|
||||
* @property-read int|null $currencies_count
|
||||
*
|
||||
* @property Collection<int, Account> $accounts
|
||||
* @property null|int $accounts_count
|
||||
* @property Collection<int, AvailableBudget> $availableBudgets
|
||||
* @property null|int $available_budgets_count
|
||||
* @property Collection<int, Bill> $bills
|
||||
* @property null|int $bills_count
|
||||
* @property Collection<int, Budget> $budgets
|
||||
* @property null|int $budgets_count
|
||||
* @property Collection<int, PiggyBank> $piggyBanks
|
||||
* @property null|int $piggy_banks_count
|
||||
* @property Collection<int, TransactionJournal> $transactionJournals
|
||||
* @property null|int $transaction_journals_count
|
||||
* @property Collection<int, Attachment> $attachments
|
||||
* @property null|int $attachments_count
|
||||
* @property Collection<int, Category> $categories
|
||||
* @property null|int $categories_count
|
||||
* @property Collection<int, CurrencyExchangeRate> $currencyExchangeRates
|
||||
* @property null|int $currency_exchange_rates_count
|
||||
* @property Collection<int, ObjectGroup> $objectGroups
|
||||
* @property null|int $object_groups_count
|
||||
* @property Collection<int, Recurrence> $recurrences
|
||||
* @property null|int $recurrences_count
|
||||
* @property Collection<int, RuleGroup> $ruleGroups
|
||||
* @property null|int $rule_groups_count
|
||||
* @property Collection<int, Rule> $rules
|
||||
* @property null|int $rules_count
|
||||
* @property Collection<int, Tag> $tags
|
||||
* @property null|int $tags_count
|
||||
* @property Collection<int, TransactionGroup> $transactionGroups
|
||||
* @property null|int $transaction_groups_count
|
||||
* @property Collection<int, Webhook> $webhooks
|
||||
* @property null|int $webhooks_count
|
||||
* @property Collection<int, TransactionCurrency> $currencies
|
||||
* @property null|int $currencies_count
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class UserGroup extends Model
|
||||
@@ -100,18 +103,17 @@ class UserGroup extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return UserGroup
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$userGroupId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var UserGroup|null $userGroup */
|
||||
|
||||
/** @var null|UserGroup $userGroup */
|
||||
$userGroup = self::find($userGroupId);
|
||||
if (null === $userGroup) {
|
||||
throw new NotFoundHttpException();
|
||||
@@ -123,13 +125,12 @@ class UserGroup extends Model
|
||||
return $userGroup;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Link to accounts.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function accounts(): HasMany
|
||||
{
|
||||
@@ -138,8 +139,6 @@ class UserGroup extends Model
|
||||
|
||||
/**
|
||||
* Link to attachments.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function attachments(): HasMany
|
||||
{
|
||||
@@ -148,8 +147,6 @@ class UserGroup extends Model
|
||||
|
||||
/**
|
||||
* Link to bills.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function availableBudgets(): HasMany
|
||||
{
|
||||
@@ -158,8 +155,6 @@ class UserGroup extends Model
|
||||
|
||||
/**
|
||||
* Link to bills.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function bills(): HasMany
|
||||
{
|
||||
@@ -168,8 +163,6 @@ class UserGroup extends Model
|
||||
|
||||
/**
|
||||
* Link to budgets.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function budgets(): HasMany
|
||||
{
|
||||
@@ -178,8 +171,6 @@ class UserGroup extends Model
|
||||
|
||||
/**
|
||||
* Link to categories.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function categories(): HasMany
|
||||
{
|
||||
@@ -188,8 +179,6 @@ class UserGroup extends Model
|
||||
|
||||
/**
|
||||
* Link to currencies
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function currencies(): BelongsToMany
|
||||
{
|
||||
@@ -198,26 +187,17 @@ class UserGroup extends Model
|
||||
|
||||
/**
|
||||
* Link to exchange rates.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function currencyExchangeRates(): HasMany
|
||||
{
|
||||
return $this->hasMany(CurrencyExchangeRate::class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function groupMemberships(): HasMany
|
||||
{
|
||||
return $this->hasMany(GroupMembership::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function objectGroups(): HasMany
|
||||
{
|
||||
return $this->hasMany(ObjectGroup::class);
|
||||
@@ -225,49 +205,32 @@ class UserGroup extends Model
|
||||
|
||||
/**
|
||||
* Link to piggy banks.
|
||||
*
|
||||
* @return HasManyThrough
|
||||
*/
|
||||
public function piggyBanks(): HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(PiggyBank::class, Account::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function recurrences(): HasMany
|
||||
{
|
||||
return $this->hasMany(Recurrence::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function ruleGroups(): HasMany
|
||||
{
|
||||
return $this->hasMany(RuleGroup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function rules(): HasMany
|
||||
{
|
||||
return $this->hasMany(Rule::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function tags(): HasMany
|
||||
{
|
||||
return $this->hasMany(Tag::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactionGroups(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionGroup::class);
|
||||
@@ -275,17 +238,12 @@ class UserGroup extends Model
|
||||
|
||||
/**
|
||||
* Link to transaction journals.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactionJournals(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function webhooks(): HasMany
|
||||
{
|
||||
return $this->hasMany(Webhook::class);
|
||||
|
||||
@@ -35,13 +35,14 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
/**
|
||||
* Class UserRole
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property string $title
|
||||
* @property-read Collection|GroupMembership[] $groupMemberships
|
||||
* @property-read int|null $group_memberships_count
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|string $deleted_at
|
||||
* @property string $title
|
||||
* @property Collection|GroupMembership[] $groupMemberships
|
||||
* @property null|int $group_memberships_count
|
||||
*
|
||||
* @method static Builder|UserRole newModelQuery()
|
||||
* @method static Builder|UserRole newQuery()
|
||||
* @method static Builder|UserRole query()
|
||||
@@ -50,6 +51,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
* @method static Builder|UserRole whereId($value)
|
||||
* @method static Builder|UserRole whereTitle($value)
|
||||
* @method static Builder|UserRole whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class UserRole extends Model
|
||||
@@ -58,10 +60,6 @@ class UserRole extends Model
|
||||
|
||||
protected $fillable = ['title'];
|
||||
|
||||
/**
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function groupMemberships(): HasMany
|
||||
{
|
||||
return $this->hasMany(GroupMembership::class);
|
||||
|
||||
@@ -42,41 +42,47 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\Webhook
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property bool $active
|
||||
* @property int $trigger
|
||||
* @property int $response
|
||||
* @property int $delivery
|
||||
* @property string $url
|
||||
* @property-read User $user
|
||||
* @property-read Collection|WebhookMessage[] $webhookMessages
|
||||
* @property-read int|null $webhook_messages_count
|
||||
* @method static Builder|Webhook newModelQuery()
|
||||
* @method static Builder|Webhook newQuery()
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property int $user_id
|
||||
* @property bool $active
|
||||
* @property int $trigger
|
||||
* @property int $response
|
||||
* @property int $delivery
|
||||
* @property string $url
|
||||
* @property User $user
|
||||
* @property Collection|WebhookMessage[] $webhookMessages
|
||||
* @property null|int $webhook_messages_count
|
||||
*
|
||||
* @method static Builder|Webhook newModelQuery()
|
||||
* @method static Builder|Webhook newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Webhook onlyTrashed()
|
||||
* @method static Builder|Webhook query()
|
||||
* @method static Builder|Webhook whereActive($value)
|
||||
* @method static Builder|Webhook whereCreatedAt($value)
|
||||
* @method static Builder|Webhook whereDeletedAt($value)
|
||||
* @method static Builder|Webhook whereDelivery($value)
|
||||
* @method static Builder|Webhook whereId($value)
|
||||
* @method static Builder|Webhook whereResponse($value)
|
||||
* @method static Builder|Webhook whereTrigger($value)
|
||||
* @method static Builder|Webhook whereUpdatedAt($value)
|
||||
* @method static Builder|Webhook whereUrl($value)
|
||||
* @method static Builder|Webhook whereUserId($value)
|
||||
* @method static Builder|Webhook query()
|
||||
* @method static Builder|Webhook whereActive($value)
|
||||
* @method static Builder|Webhook whereCreatedAt($value)
|
||||
* @method static Builder|Webhook whereDeletedAt($value)
|
||||
* @method static Builder|Webhook whereDelivery($value)
|
||||
* @method static Builder|Webhook whereId($value)
|
||||
* @method static Builder|Webhook whereResponse($value)
|
||||
* @method static Builder|Webhook whereTrigger($value)
|
||||
* @method static Builder|Webhook whereUpdatedAt($value)
|
||||
* @method static Builder|Webhook whereUrl($value)
|
||||
* @method static Builder|Webhook whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Webhook withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Webhook withoutTrashed()
|
||||
* @property string $title
|
||||
* @property string $secret
|
||||
*
|
||||
* @property string $title
|
||||
* @property string $secret
|
||||
*
|
||||
* @method static Builder|Webhook whereSecret($value)
|
||||
* @method static Builder|Webhook whereTitle($value)
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static Builder|Webhook whereUserGroupId($value)
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Webhook extends Model
|
||||
@@ -87,16 +93,13 @@ class Webhook extends Model
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'active' => 'boolean',
|
||||
'trigger' => 'integer',
|
||||
'response' => 'integer',
|
||||
'delivery' => 'integer',
|
||||
];
|
||||
'active' => 'boolean',
|
||||
'trigger' => 'integer',
|
||||
'response' => 'integer',
|
||||
'delivery' => 'integer',
|
||||
];
|
||||
protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'user_group_id', 'url', 'title', 'secret'];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getDeliveries(): array
|
||||
{
|
||||
$array = [];
|
||||
@@ -104,12 +107,10 @@ class Webhook extends Model
|
||||
foreach ($set as $item) {
|
||||
$array[$item->value] = $item->name;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getDeliveriesForValidation(): array
|
||||
{
|
||||
$array = [];
|
||||
@@ -118,12 +119,10 @@ class Webhook extends Model
|
||||
$array[$item->name] = $item->value;
|
||||
$array[$item->value] = $item->value;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getResponses(): array
|
||||
{
|
||||
$array = [];
|
||||
@@ -131,12 +130,10 @@ class Webhook extends Model
|
||||
foreach ($set as $item) {
|
||||
$array[$item->value] = $item->name;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getResponsesForValidation(): array
|
||||
{
|
||||
$array = [];
|
||||
@@ -145,12 +142,10 @@ class Webhook extends Model
|
||||
$array[$item->name] = $item->value;
|
||||
$array[$item->value] = $item->value;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getTriggers(): array
|
||||
{
|
||||
$array = [];
|
||||
@@ -158,12 +153,10 @@ class Webhook extends Model
|
||||
foreach ($set as $item) {
|
||||
$array[$item->value] = $item->name;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getTriggersForValidation(): array
|
||||
{
|
||||
$array = [];
|
||||
@@ -172,43 +165,38 @@ class Webhook extends Model
|
||||
$array[$item->name] = $item->value;
|
||||
$array[$item->value] = $item->value;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Webhook
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$webhookId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Webhook|null $webhook */
|
||||
|
||||
/** @var null|Webhook $webhook */
|
||||
$webhook = $user->webhooks()->find($webhookId);
|
||||
if (null !== $webhook) {
|
||||
return $webhook;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function webhookMessages(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebhookMessage::class);
|
||||
|
||||
@@ -37,15 +37,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class WebhookAttempt
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property int $webhook_message_id
|
||||
* @property int|string $status_code
|
||||
* @property string|null $logs
|
||||
* @property string|null $response
|
||||
* @property-read WebhookMessage $webhookMessage
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|string $deleted_at
|
||||
* @property int $webhook_message_id
|
||||
* @property int|string $status_code
|
||||
* @property null|string $logs
|
||||
* @property null|string $response
|
||||
* @property WebhookMessage $webhookMessage
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt query()
|
||||
@@ -57,9 +58,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt whereStatusCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt whereWebhookMessageId($value)
|
||||
* @method static Builder|WebhookAttempt onlyTrashed()
|
||||
* @method static Builder|WebhookAttempt withTrashed()
|
||||
* @method static Builder|WebhookAttempt withoutTrashed()
|
||||
* @method static Builder|WebhookAttempt onlyTrashed()
|
||||
* @method static Builder|WebhookAttempt withTrashed()
|
||||
* @method static Builder|WebhookAttempt withoutTrashed()
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class WebhookAttempt extends Model
|
||||
@@ -70,41 +72,35 @@ class WebhookAttempt extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return WebhookAttempt
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$attemptId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var WebhookAttempt|null $attempt */
|
||||
|
||||
/** @var null|WebhookAttempt $attempt */
|
||||
$attempt = self::find($attemptId);
|
||||
if (null !== $attempt && $attempt->webhookMessage->webhook->user_id === $user->id) {
|
||||
return $attempt;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function webhookMessage(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WebhookMessage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function webhookMessageId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,18 +38,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\WebhookMessage
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property int $webhook_id
|
||||
* @property bool $sent
|
||||
* @property bool $errored
|
||||
* @property int $attempts
|
||||
* @property string $uuid
|
||||
* @property array $message
|
||||
* @property array|null $logs
|
||||
* @property-read Webhook $webhook
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|string $deleted_at
|
||||
* @property int $webhook_id
|
||||
* @property bool $sent
|
||||
* @property bool $errored
|
||||
* @property int $attempts
|
||||
* @property string $uuid
|
||||
* @property array $message
|
||||
* @property null|array $logs
|
||||
* @property Webhook $webhook
|
||||
*
|
||||
* @method static Builder|WebhookMessage newModelQuery()
|
||||
* @method static Builder|WebhookMessage newQuery()
|
||||
* @method static Builder|WebhookMessage query()
|
||||
@@ -64,8 +65,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|WebhookMessage whereUpdatedAt($value)
|
||||
* @method static Builder|WebhookMessage whereUuid($value)
|
||||
* @method static Builder|WebhookMessage whereWebhookId($value)
|
||||
* @property-read Collection|WebhookAttempt[] $webhookAttempts
|
||||
* @property-read int|null $webhook_attempts_count
|
||||
*
|
||||
* @property Collection|WebhookAttempt[] $webhookAttempts
|
||||
* @property null|int $webhook_attempts_count
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class WebhookMessage extends Model
|
||||
@@ -84,37 +87,31 @@ class WebhookMessage extends Model
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return WebhookMessage
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$messageId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var WebhookMessage|null $message */
|
||||
|
||||
/** @var null|WebhookMessage $message */
|
||||
$message = self::find($messageId);
|
||||
if (null !== $message && $message->webhook->user_id === $user->id) {
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function webhook(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Webhook::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function webhookAttempts(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebhookAttempt::class);
|
||||
@@ -122,23 +119,18 @@ class WebhookMessage extends Model
|
||||
|
||||
/**
|
||||
* Get the amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function sent(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (bool)$value,
|
||||
get: static fn ($value) => (bool)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function webhookId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user