Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:42:26 +01:00
parent dbf3e76ecc
commit 6cfdc58cb1
415 changed files with 7462 additions and 6874 deletions

View File

@@ -1,4 +1,5 @@
<?php
/**
* Account.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -39,36 +40,36 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Account
*
* @property int $id
* @property int $id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property int $user_id
* @property int $account_type_id
* @property string $name
* @property string|null $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 $user_id
* @property int $account_type_id
* @property string $name
* @property string|null $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
* @method static EloquentBuilder|Account accountTypeIn($types)
* @method static EloquentBuilder|Account newModelQuery()
* @method static EloquentBuilder|Account newQuery()
@@ -89,17 +90,17 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Account withTrashed()
* @method static Builder|Account withoutTrashed()
* @mixin Eloquent
* @property Carbon $lastActivityDate
* @property string $startBalance
* @property string $endBalance
* @property string $difference
* @property string $interest
* @property string $interestPeriod
* @property string $accountTypeString
* @property string $location
* @property string $liability_direction
* @property string $current_debt
* @property int|null $user_group_id
* @property Carbon $lastActivityDate
* @property string $startBalance
* @property string $endBalance
* @property string $difference
* @property string $interest
* @property string $interestPeriod
* @property string $accountTypeString
* @property string $location
* @property string $liability_direction
* @property string $current_debt
* @property int|null $user_group_id
* @method static EloquentBuilder|Account whereUserGroupId($value)
*/
class Account extends Model
@@ -124,13 +125,13 @@ class Account extends Model
/** @var array Fields that can be filled */
protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
/** @var array Hidden from view */
protected $hidden = ['encrypted'];
protected $hidden = ['encrypted'];
private bool $joinedAccountTypes = false;
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return Account
* @throws NotFoundHttpException
@@ -138,7 +139,7 @@ class Account extends Model
public static function routeBinder(string $value): Account
{
if (auth()->check()) {
$accountId = (int) $value;
$accountId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Account $account */
@@ -150,6 +151,15 @@ class Account extends Model
throw new NotFoundHttpException();
}
/**
* @return BelongsTo
* @codeCoverageIgnore
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @return BelongsTo
* @codeCoverageIgnore
@@ -245,8 +255,8 @@ class Account extends Model
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param array $types
* @param EloquentBuilder $query
* @param array $types
*/
public function scopeAccountTypeIn(EloquentBuilder $query, array $types): void
{
@@ -260,13 +270,13 @@ class Account extends Model
/**
* @codeCoverageIgnore
*
* @param mixed $value
* @param mixed $value
*
* @codeCoverageIgnore
*/
public function setVirtualBalanceAttribute($value): void
{
$value = (string) $value;
$value = (string)$value;
if ('' === $value) {
$value = null;
}
@@ -281,13 +291,4 @@ class Account extends Model
{
return $this->hasMany(Transaction::class);
}
/**
* @return BelongsTo
* @codeCoverageIgnore
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* AccountMeta.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -32,12 +33,12 @@ use JsonException;
/**
* 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 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
* @method static Builder|AccountMeta newModelQuery()
* @method static Builder|AccountMeta newQuery()
@@ -77,7 +78,7 @@ class AccountMeta extends Model
}
/**
* @param mixed $value
* @param mixed $value
*
* @return mixed
* @throws JsonException
@@ -89,7 +90,7 @@ class AccountMeta extends Model
}
/**
* @param mixed $value
* @param mixed $value
*
* @codeCoverageIgnore
*/

View File

@@ -1,4 +1,5 @@
<?php
/**
* AccountType.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -32,12 +33,12 @@ use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\AccountType
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string $type
* @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-read int|null $accounts_count
* @method static Builder|AccountType newModelQuery()
* @method static Builder|AccountType newQuery()
* @method static Builder|AccountType query()

View File

@@ -1,4 +1,5 @@
<?php
/**
* Attachment.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -37,26 +38,26 @@ 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 $size
* @property bool $uploaded
* @property string $notes_text
* @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 $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 Collection|Note[] $notes
* @property-read int|null $notes_count
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|Attachment newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Attachment newQuery()
* @method static Builder|Attachment onlyTrashed()
@@ -78,7 +79,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Attachment withTrashed()
* @method static Builder|Attachment withoutTrashed()
* @mixin Eloquent
* @property int|null $user_group_id
* @property int|null $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUserGroupId($value)
*/
class Attachment extends Model
@@ -103,7 +104,7 @@ class Attachment extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return Attachment
* @throws NotFoundHttpException
@@ -111,7 +112,7 @@ class Attachment extends Model
public static function routeBinder(string $value): Attachment
{
if (auth()->check()) {
$attachmentId = (int) $value;
$attachmentId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Attachment $attachment */
@@ -123,6 +124,15 @@ class Attachment extends Model
throw new NotFoundHttpException();
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Get all of the owning attachable models.
*
@@ -143,7 +153,7 @@ class Attachment extends Model
*/
public function fileName(): string
{
return sprintf('at-%s.data', (string) $this->id);
return sprintf('at-%s.data', (string)$this->id);
}
/**
@@ -154,13 +164,4 @@ class Attachment extends Model
{
return $this->morphMany(Note::class, 'noteable');
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -24,22 +24,47 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;
/**
* Class AuditLogEntry
*
* @property-read Model|\Eloquent $auditable
* @property-read Model|\Eloquent $changer
* @method static \Illuminate\Database\Eloquent\Builder|AuditLogEntry newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|AuditLogEntry newQuery()
* @property-read Model|Eloquent $auditable
* @property-read Model|Eloquent $changer
* @method static Builder|AuditLogEntry newModelQuery()
* @method static Builder|AuditLogEntry newQuery()
* @method static \Illuminate\Database\Query\Builder|AuditLogEntry onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|AuditLogEntry query()
* @method static Builder|AuditLogEntry query()
* @method static \Illuminate\Database\Query\Builder|AuditLogEntry withTrashed()
* @method static \Illuminate\Database\Query\Builder|AuditLogEntry withoutTrashed()
* @mixin \Eloquent
* @mixin Eloquent
* @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
* @method static Builder|AuditLogEntry whereAction($value)
* @method static Builder|AuditLogEntry whereAfter($value)
* @method static Builder|AuditLogEntry whereAuditableId($value)
* @method static Builder|AuditLogEntry whereAuditableType($value)
* @method static Builder|AuditLogEntry whereBefore($value)
* @method static Builder|AuditLogEntry whereChangerId($value)
* @method static Builder|AuditLogEntry whereChangerType($value)
* @method static Builder|AuditLogEntry whereCreatedAt($value)
* @method static Builder|AuditLogEntry whereDeletedAt($value)
* @method static Builder|AuditLogEntry whereId($value)
* @method static Builder|AuditLogEntry whereUpdatedAt($value)
*/
class AuditLogEntry extends Model
{

View File

@@ -34,16 +34,16 @@ use Illuminate\Support\Carbon;
/**
* 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 $auto_budget_type
* @property string $amount
* @property string $period
* @property-read Budget $budget
* @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 $auto_budget_type
* @property string $amount
* @property string $period
* @property-read Budget $budget
* @property-read TransactionCurrency $transactionCurrency
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|AutoBudget newQuery()
@@ -65,7 +65,8 @@ use Illuminate\Support\Carbon;
class AutoBudget extends Model
{
use SoftDeletes;
public const AUTO_BUDGET_RESET = 1;
public const AUTO_BUDGET_RESET = 1;
public const AUTO_BUDGET_ROLLOVER = 2;
/**

View File

@@ -1,4 +1,5 @@
<?php
/**
* AvailableBudget.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -34,17 +35,17 @@ 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 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-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget newQuery()
* @method static Builder|AvailableBudget onlyTrashed()
@@ -61,7 +62,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|AvailableBudget withTrashed()
* @method static Builder|AvailableBudget withoutTrashed()
* @mixin Eloquent
* @property int|null $user_group_id
* @property int|null $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereUserGroupId($value)
*/
class AvailableBudget extends Model
@@ -88,7 +89,7 @@ class AvailableBudget extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return AvailableBudget
* @throws NotFoundHttpException
@@ -96,7 +97,7 @@ class AvailableBudget extends Model
public static function routeBinder(string $value): AvailableBudget
{
if (auth()->check()) {
$availableBudgetId = (int) $value;
$availableBudgetId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var AvailableBudget $availableBudget */
@@ -112,17 +113,17 @@ class AvailableBudget extends Model
* @codeCoverageIgnore
* @return BelongsTo
*/
public function transactionCurrency(): BelongsTo
public function user(): BelongsTo
{
return $this->belongsTo(TransactionCurrency::class);
return $this->belongsTo(User::class);
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
public function transactionCurrency(): BelongsTo
{
return $this->belongsTo(User::class);
return $this->belongsTo(TransactionCurrency::class);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Bill.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -38,36 +39,36 @@ 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|null $transaction_currency_id
* @property string $name
* @property string $match
* @property string $amount_min
* @property string $amount_max
* @property Carbon $date
* @property string|null $end_date
* @property string|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 int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property int $user_id
* @property int|null $transaction_currency_id
* @property string $name
* @property string $match
* @property string $amount_min
* @property string $amount_max
* @property Carbon $date
* @property string|null $end_date
* @property string|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-read int|null $transaction_journals_count
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|Bill newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Bill newQuery()
* @method static Builder|Bill onlyTrashed()
@@ -95,7 +96,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Bill withTrashed()
* @method static Builder|Bill withoutTrashed()
* @mixin Eloquent
* @property int|null $user_group_id
* @property int|null $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserGroupId($value)
*/
class Bill extends Model
@@ -124,15 +125,28 @@ class Bill extends Model
/** @var array Fields that can be filled */
protected $fillable
= ['name', 'match', 'amount_min', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
'automatch', 'active', 'transaction_currency_id', 'end_date', 'extension_date'];
= [
'name',
'match',
'amount_min',
'user_id',
'amount_max',
'date',
'repeat_freq',
'skip',
'automatch',
'active',
'transaction_currency_id',
'end_date',
'extension_date',
];
/** @var array Hidden from view */
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return Bill
* @throws NotFoundHttpException
@@ -140,7 +154,7 @@ class Bill extends Model
public static function routeBinder(string $value): Bill
{
if (auth()->check()) {
$billId = (int) $value;
$billId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Bill $bill */
@@ -152,6 +166,15 @@ class Bill extends Model
throw new NotFoundHttpException();
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @codeCoverageIgnore
* @return MorphMany
@@ -181,21 +204,21 @@ class Bill extends Model
/**
* @codeCoverageIgnore
*
* @param mixed $value
* @param mixed $value
*/
public function setAmountMaxAttribute($value): void
{
$this->attributes['amount_max'] = (string) $value;
$this->attributes['amount_max'] = (string)$value;
}
/**
* @param mixed $value
* @param mixed $value
*
* @codeCoverageIgnore
*/
public function setAmountMinAttribute($value): void
{
$this->attributes['amount_min'] = (string) $value;
$this->attributes['amount_min'] = (string)$value;
}
/**
@@ -216,15 +239,6 @@ class Bill extends Model
return $this->hasMany(TransactionJournal::class);
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Get the max amount
*
@@ -233,7 +247,7 @@ class Bill extends Model
protected function amountMax(): Attribute
{
return Attribute::make(
get: fn ($value) => (string) $value,
get: fn ($value) => (string)$value,
);
}
@@ -245,7 +259,7 @@ class Bill extends Model
protected function amountMin(): Attribute
{
return Attribute::make(
get: fn ($value) => (string) $value,
get: fn ($value) => (string)$value,
);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Budget.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -38,26 +39,26 @@ 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 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
* @method static \Illuminate\Database\Eloquent\Builder|Budget newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Budget newQuery()
* @method static Builder|Budget onlyTrashed()
@@ -74,11 +75,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Budget withTrashed()
* @method static Builder|Budget withoutTrashed()
* @mixin Eloquent
* @property string $email
* @property int|null $user_group_id
* @property string $email
* @property int|null $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Budget whereUserGroupId($value)
* @property-read Collection|Note[] $notes
* @property-read int|null $notes_count
* @property-read int|null $notes_count
*/
class Budget extends Model
{
@@ -105,7 +106,7 @@ class Budget extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return Budget
* @throws NotFoundHttpException
@@ -113,7 +114,7 @@ class Budget extends Model
public static function routeBinder(string $value): Budget
{
if (auth()->check()) {
$budgetId = (int) $value;
$budgetId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Budget $budget */
@@ -125,6 +126,15 @@ class Budget extends Model
throw new NotFoundHttpException();
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @codeCoverageIgnore
* @return MorphMany
@@ -178,13 +188,4 @@ class Budget extends Model
{
return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id');
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* BudgetLimit.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -33,18 +34,18 @@ 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|null $transaction_currency_id
* @property Carbon $start_date
* @property Carbon|null $end_date
* @property string $amount
* @property string $spent
* @property string|null $period
* @property int $generated
* @property-read Budget $budget
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property int $budget_id
* @property int|null $transaction_currency_id
* @property Carbon $start_date
* @property Carbon|null $end_date
* @property string $amount
* @property string $spent
* @property string|null $period
* @property int $generated
* @property-read Budget $budget
* @property-read TransactionCurrency|null $transactionCurrency
* @method static Builder|BudgetLimit newModelQuery()
* @method static Builder|BudgetLimit newQuery()
@@ -83,7 +84,7 @@ class BudgetLimit extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return BudgetLimit
* @throws NotFoundHttpException
@@ -91,7 +92,7 @@ class BudgetLimit extends Model
public static function routeBinder(string $value): BudgetLimit
{
if (auth()->check()) {
$budgetLimitId = (int) $value;
$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)
@@ -129,7 +130,7 @@ class BudgetLimit extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: fn ($value) => (string) $value,
get: fn ($value) => (string)$value,
);
}
}

View File

@@ -38,23 +38,23 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Category
*
* @property int $id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\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 int $id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\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-read int|null $transaction_journals_count
* @property-read Collection|Transaction[] $transactions
* @property-read int|null $transactions_count
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|Category newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Category newQuery()
* @method static Builder|Category onlyTrashed()
@@ -69,7 +69,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Category withTrashed()
* @method static Builder|Category withoutTrashed()
* @mixin Eloquent
* @property int|null $user_group_id
* @property int|null $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Category whereUserGroupId($value)
*/
class Category extends Model
@@ -96,7 +96,7 @@ class Category extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return Category
* @throws NotFoundHttpException
@@ -104,7 +104,7 @@ class Category extends Model
public static function routeBinder(string $value): Category
{
if (auth()->check()) {
$categoryId = (int) $value;
$categoryId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Category $category */
@@ -116,6 +116,15 @@ class Category extends Model
throw new NotFoundHttpException();
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @codeCoverageIgnore
* @return MorphMany
@@ -151,13 +160,4 @@ class Category extends Model
{
return $this->belongsToMany(Transaction::class, 'category_transaction', 'category_id');
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Configuration.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -31,12 +32,12 @@ use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\Configuration
*
* @property int $id
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property string $name
* @property mixed $data
* @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()
@@ -74,7 +75,7 @@ class Configuration extends Model
*
* @codeCoverageIgnore
*
* @param mixed $value
* @param mixed $value
*
* @return mixed
*/
@@ -86,7 +87,7 @@ class Configuration extends Model
/**
* @codeCoverageIgnore
*
* @param mixed $value
* @param mixed $value
*/
public function setDataAttribute($value): void
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* CurrencyExchangeRate.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -24,39 +25,43 @@ namespace FireflyIII\Models;
use Eloquent;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
/**
* Class CurrencyExchangeRate
*
* @property int $id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @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 \Illuminate\Support\Carbon $date
* @property Carbon $date
* @property string $rate
* @property string|null $user_rate
* @property-read \FireflyIII\Models\TransactionCurrency $fromCurrency
* @property-read \FireflyIII\Models\TransactionCurrency $toCurrency
* @property-read TransactionCurrency $fromCurrency
* @property-read TransactionCurrency $toCurrency
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate query()
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereFromCurrencyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereRate($value)
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereToCurrencyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|CurrencyExchangeRate whereUserRate($value)
* @method static Builder|CurrencyExchangeRate newModelQuery()
* @method static Builder|CurrencyExchangeRate newQuery()
* @method static Builder|CurrencyExchangeRate query()
* @method static Builder|CurrencyExchangeRate whereCreatedAt($value)
* @method static Builder|CurrencyExchangeRate whereDate($value)
* @method static Builder|CurrencyExchangeRate whereDeletedAt($value)
* @method static Builder|CurrencyExchangeRate whereFromCurrencyId($value)
* @method static Builder|CurrencyExchangeRate whereId($value)
* @method static Builder|CurrencyExchangeRate whereRate($value)
* @method static Builder|CurrencyExchangeRate whereToCurrencyId($value)
* @method static Builder|CurrencyExchangeRate whereUpdatedAt($value)
* @method static Builder|CurrencyExchangeRate whereUserId($value)
* @method static Builder|CurrencyExchangeRate whereUserRate($value)
* @mixin Eloquent
* @property int|null $user_group_id
* @method static Builder|CurrencyExchangeRate whereUserGroupId($value)
*/
class CurrencyExchangeRate extends Model
{

View File

@@ -34,16 +34,16 @@ use Illuminate\Support\Carbon;
/**
* 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 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-read UserRole $userRole
* @method static Builder|GroupMembership newModelQuery()
* @method static Builder|GroupMembership newQuery()
* @method static Builder|GroupMembership query()

View File

@@ -24,28 +24,46 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
/**
* Class InvitedUser
*
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|InvitedUser newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|InvitedUser newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|InvitedUser query()
* @mixin \Eloquent
* @method static Builder|InvitedUser newModelQuery()
* @method static Builder|InvitedUser newQuery()
* @method static Builder|InvitedUser query()
* @mixin Eloquent
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $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)
* @method static Builder|InvitedUser whereId($value)
* @method static Builder|InvitedUser whereInviteCode($value)
* @method static Builder|InvitedUser whereRedeemed($value)
* @method static Builder|InvitedUser whereUpdatedAt($value)
* @method static Builder|InvitedUser whereUserId($value)
*/
class InvitedUser extends Model
{
protected $fillable = ['user_id', 'email', 'invite_code', 'expires', 'redeemed'];
protected $casts
= [
'expires' => 'datetime',
'redeemed' => 'boolean',
];
protected $fillable = ['user_id', 'email', 'invite_code', 'expires', 'redeemed'];
/**
* @codeCoverageIgnore

View File

@@ -1,4 +1,5 @@
<?php
/**
* LinkType.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -34,17 +35,17 @@ 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 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-read int|null $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()
@@ -84,7 +85,7 @@ class LinkType extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return LinkType
*
@@ -93,7 +94,7 @@ class LinkType extends Model
public static function routeBinder(string $value): LinkType
{
if (auth()->check()) {
$linkTypeId = (int) $value;
$linkTypeId = (int)$value;
$linkType = self::find($linkTypeId);
if (null !== $linkType) {
return $linkType;

View File

@@ -35,18 +35,18 @@ use Illuminate\Support\Carbon;
/**
* 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 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-read int|null $accounts_count
* @property-read Model|Eloquent $locatable
* @method static Builder|Location newModelQuery()
* @method static Builder|Location newQuery()
* @method static Builder|Location query()
@@ -83,7 +83,7 @@ class Location extends Model
/**
* Add rules for locations.
*
* @param array $rules
* @param array $rules
*
* @return array
*/

View File

@@ -1,4 +1,5 @@
<?php
/**
* Note.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -32,14 +33,14 @@ use Illuminate\Support\Carbon;
/**
* 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 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
* @method static \Illuminate\Database\Eloquent\Builder|Note newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Note newQuery()

View File

@@ -37,20 +37,20 @@ 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 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-read int|null $piggy_banks_count
* @property-read User $user
* @method static Builder|ObjectGroup newModelQuery()
* @method static Builder|ObjectGroup newQuery()
* @method static Builder|ObjectGroup query()
@@ -82,7 +82,7 @@ class ObjectGroup extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return ObjectGroup
* @throws NotFoundHttpException
@@ -90,7 +90,7 @@ class ObjectGroup extends Model
public static function routeBinder(string $value): ObjectGroup
{
if (auth()->check()) {
$objectGroupId = (int) $value;
$objectGroupId = (int)$value;
/** @var ObjectGroup $objectGroup */
$objectGroup = self::where('object_groups.id', $objectGroupId)
->where('object_groups.user_id', auth()->user()->id)->first();
@@ -101,6 +101,15 @@ class ObjectGroup extends Model
throw new NotFoundHttpException();
}
/**
* @return BelongsTo
* @codeCoverageIgnore
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @return MorphToMany
*/
@@ -124,13 +133,4 @@ class ObjectGroup extends Model
{
return $this->morphedByMany(PiggyBank::class, 'object_groupable');
}
/**
* @return BelongsTo
* @codeCoverageIgnore
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* PiggyBank.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -37,29 +38,29 @@ 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 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-read int|null $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()
@@ -108,7 +109,7 @@ class PiggyBank extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return PiggyBank
* @throws NotFoundHttpException
@@ -116,7 +117,7 @@ class PiggyBank extends Model
public static function routeBinder(string $value): PiggyBank
{
if (auth()->check()) {
$piggyBankId = (int) $value;
$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.*']);
@@ -183,11 +184,11 @@ class PiggyBank extends Model
/**
* @codeCoverageIgnore
*
* @param mixed $value
* @param mixed $value
*/
public function setTargetamountAttribute($value): void
{
$this->attributes['targetamount'] = (string) $value;
$this->attributes['targetamount'] = (string)$value;
}
/**
@@ -198,7 +199,7 @@ class PiggyBank extends Model
protected function targetamount(): Attribute
{
return Attribute::make(
get: fn ($value) => (string) $value,
get: fn ($value) => (string)$value,
);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* PiggyBankEvent.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -32,14 +33,14 @@ use Illuminate\Support\Carbon;
/**
* 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 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
* @method static Builder|PiggyBankEvent newModelQuery()
* @method static Builder|PiggyBankEvent newQuery()
@@ -83,11 +84,11 @@ class PiggyBankEvent extends Model
/**
* @codeCoverageIgnore
*
* @param mixed $value
* @param mixed $value
*/
public function setAmountAttribute($value): void
{
$this->attributes['amount'] = (string) $value;
$this->attributes['amount'] = (string)$value;
}
/**
@@ -107,7 +108,7 @@ class PiggyBankEvent extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: fn ($value) => (string) $value,
get: fn ($value) => (string)$value,
);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* PiggyBankRepetition.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -32,14 +33,14 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* FireflyIII\Models\PiggyBankRepetition
*
* @property int $id
* @property int $id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property int $piggy_bank_id
* @property int $piggy_bank_id
* @property \Illuminate\Support\Carbon|null $startdate
* @property \Illuminate\Support\Carbon|null $targetdate
* @property string $currentamount
* @property-read PiggyBank $piggyBank
* @property string $currentamount
* @property-read PiggyBank $piggyBank
* @method static EloquentBuilder|PiggyBankRepetition newModelQuery()
* @method static EloquentBuilder|PiggyBankRepetition newQuery()
* @method static EloquentBuilder|PiggyBankRepetition onDates(Carbon $start, Carbon $target)
@@ -83,9 +84,9 @@ class PiggyBankRepetition extends Model
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param Carbon $start
* @param Carbon $target
* @param EloquentBuilder $query
* @param Carbon $start
* @param Carbon $target
*
* @return EloquentBuilder
*/
@@ -97,8 +98,8 @@ class PiggyBankRepetition extends Model
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param Carbon $date
* @param EloquentBuilder $query
* @param Carbon $date
*
* @return EloquentBuilder
*/
@@ -121,11 +122,11 @@ class PiggyBankRepetition extends Model
/**
* @codeCoverageIgnore
*
* @param mixed $value
* @param mixed $value
*/
public function setCurrentamountAttribute($value): void
{
$this->attributes['currentamount'] = (string) $value;
$this->attributes['currentamount'] = (string)$value;
}
/**
@@ -136,7 +137,7 @@ class PiggyBankRepetition extends Model
protected function currentamount(): Attribute
{
return Attribute::make(
get: fn ($value) => (string) $value,
get: fn ($value) => (string)$value,
);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Preference.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -33,13 +34,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Preference
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property int $user_id
* @property string $name
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property int $user_id
* @property string $name
* @property int|string|array|null $data
* @property-read User $user
* @property-read User $user
* @method static Builder|Preference newModelQuery()
* @method static Builder|Preference newQuery()
* @method static Builder|Preference query()
@@ -71,7 +72,7 @@ class Preference extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return Preference
* @throws NotFoundHttpException
@@ -84,7 +85,7 @@ class Preference extends Model
/** @var Preference|null $preference */
$preference = $user->preferences()->where('name', $value)->first();
if (null === $preference) {
$preference = $user->preferences()->where('id', (int) $value)->first();
$preference = $user->preferences()->where('id', (int)$value)->first();
}
if (null !== $preference) {
return $preference;

View File

@@ -38,33 +38,33 @@ 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 $first_date
* @property Carbon|null $repeat_until
* @property Carbon|null $latest_date
* @property int $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 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 $first_date
* @property Carbon|null $repeat_until
* @property Carbon|null $latest_date
* @property int $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-read int|null $recurrence_transactions_count
* @property-read TransactionCurrency $transactionCurrency
* @property-read TransactionType $transactionType
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence newQuery()
* @method static Builder|Recurrence onlyTrashed()
@@ -86,7 +86,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Recurrence withTrashed()
* @method static Builder|Recurrence withoutTrashed()
* @mixin Eloquent
* @property int|null $user_group_id
* @property int|null $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereUserGroupId($value)
*/
class Recurrence extends Model
@@ -122,7 +122,7 @@ class Recurrence extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return Recurrence
* @throws NotFoundHttpException
@@ -130,7 +130,7 @@ class Recurrence extends Model
public static function routeBinder(string $value): Recurrence
{
if (auth()->check()) {
$recurrenceId = (int) $value;
$recurrenceId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Recurrence $recurrence */
@@ -142,6 +142,15 @@ class Recurrence extends Model
throw new NotFoundHttpException();
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @codeCoverageIgnore
* @return MorphMany
@@ -204,13 +213,4 @@ class Recurrence extends Model
{
return $this->belongsTo(TransactionType::class);
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -33,13 +33,13 @@ use Illuminate\Support\Carbon;
/**
* 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 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
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceMeta newQuery()

View File

@@ -33,15 +33,15 @@ use Illuminate\Support\Carbon;
/**
* 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 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
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newQuery()
@@ -63,6 +63,7 @@ use Illuminate\Support\Carbon;
class RecurrenceRepetition extends Model
{
use SoftDeletes;
public const WEEKEND_DO_NOTHING = 1;
public const WEEKEND_SKIP_CREATION = 2;
public const WEEKEND_TO_FRIDAY = 3;

View File

@@ -35,25 +35,25 @@ use Illuminate\Support\Carbon;
/**
* 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|null $foreign_currency_id
* @property int $source_id
* @property int $destination_id
* @property string $amount
* @property string|null $foreign_amount
* @property string $description
* @property-read Account $destinationAccount
* @property-read TransactionCurrency|null $foreignCurrency
* @property-read Recurrence $recurrence
* @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|null $foreign_currency_id
* @property int $source_id
* @property int $destination_id
* @property string $amount
* @property string|null $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-read int|null $recurrence_transaction_meta_count
* @property-read Account $sourceAccount
* @property-read TransactionCurrency $transactionCurrency
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction newQuery()
* @method static Builder|RecurrenceTransaction onlyTrashed()
@@ -73,9 +73,9 @@ use Illuminate\Support\Carbon;
* @method static Builder|RecurrenceTransaction withTrashed()
* @method static Builder|RecurrenceTransaction withoutTrashed()
* @mixin Eloquent
* @property int|null $transaction_type_id
* @property int|null $transaction_type_id
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction whereTransactionTypeId($value)
* @property-read TransactionType|null $transactionType
* @property-read TransactionType|null $transactionType
*/
class RecurrenceTransaction extends Model
{
@@ -97,8 +97,16 @@ class RecurrenceTransaction extends Model
];
/** @var array Fields that can be filled */
protected $fillable
= ['recurrence_id', 'transaction_currency_id', 'foreign_currency_id', 'source_id', 'destination_id', 'amount', 'foreign_amount',
'description'];
= [
'recurrence_id',
'transaction_currency_id',
'foreign_currency_id',
'source_id',
'destination_id',
'amount',
'foreign_amount',
'description',
];
/** @var string The table to store the data in */
protected $table = 'recurrences_transactions';

View File

@@ -33,13 +33,13 @@ use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\RecurrenceTransactionMeta
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property int $rt_id
* @property string $name
* @property mixed $value
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property int $rt_id
* @property string $name
* @property mixed $value
* @property-read RecurrenceTransaction $recurrenceTransaction
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransactionMeta newQuery()

View File

@@ -1,4 +1,5 @@
<?php
/**
* Role.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -33,14 +34,14 @@ use Illuminate\Support\Carbon;
/**
* 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 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-read int|null $users_count
* @method static Builder|Role newModelQuery()
* @method static Builder|Role newQuery()
* @method static Builder|Role query()

View File

@@ -1,4 +1,5 @@
<?php
/**
* Rule.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -36,25 +37,25 @@ 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 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-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
* @method static \Illuminate\Database\Eloquent\Builder|Rule newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Rule newQuery()
* @method static Builder|Rule onlyTrashed()
@@ -74,7 +75,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Rule withTrashed()
* @method static Builder|Rule withoutTrashed()
* @mixin Eloquent
* @property int|null $user_group_id
* @property int|null $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereUserGroupId($value)
*/
class Rule extends Model
@@ -103,7 +104,7 @@ class Rule extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return Rule
* @throws NotFoundHttpException
@@ -111,7 +112,7 @@ class Rule extends Model
public static function routeBinder(string $value): Rule
{
if (auth()->check()) {
$ruleId = (int) $value;
$ruleId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Rule $rule */
@@ -123,6 +124,15 @@ class Rule extends Model
throw new NotFoundHttpException();
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @codeCoverageIgnore
* @return HasMany
@@ -151,7 +161,7 @@ class Rule extends Model
}
/**
* @param mixed $value
* @param mixed $value
*
* @codeCoverageIgnore
*/
@@ -159,13 +169,4 @@ class Rule extends Model
{
$this->attributes['description'] = e($value);
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* RuleAction.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -31,16 +32,16 @@ use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\RuleAction
*
* @property int $id
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property int $rule_id
* @property string $action_type
* @property string $action_value
* @property int $order
* @property bool $active
* @property bool $stop_processing
* @property-read Rule $rule
* @property int $rule_id
* @property string $action_type
* @property string $action_value
* @property int $order
* @property bool $active
* @property bool $stop_processing
* @property-read Rule $rule
* @method static Builder|RuleAction newModelQuery()
* @method static Builder|RuleAction newQuery()
* @method static Builder|RuleAction query()

View File

@@ -1,4 +1,5 @@
<?php
/**
* RuleGroup.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -36,19 +37,19 @@ 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 int $user_id
* @property string $title
* @property string|null $description
* @property int $order
* @property bool $active
* @property bool $stop_processing
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property int $user_id
* @property string $title
* @property string|null $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-read int|null $rules_count
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newQuery()
* @method static Builder|RuleGroup onlyTrashed()
@@ -66,7 +67,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|RuleGroup withTrashed()
* @method static Builder|RuleGroup withoutTrashed()
* @mixin Eloquent
* @property int|null $user_group_id
* @property int|null $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserGroupId($value)
*/
class RuleGroup extends Model
@@ -94,7 +95,7 @@ class RuleGroup extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return RuleGroup
* @throws NotFoundHttpException
@@ -102,7 +103,7 @@ class RuleGroup extends Model
public static function routeBinder(string $value): RuleGroup
{
if (auth()->check()) {
$ruleGroupId = (int) $value;
$ruleGroupId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var RuleGroup $ruleGroup */
@@ -114,15 +115,6 @@ class RuleGroup extends Model
throw new NotFoundHttpException();
}
/**
* @codeCoverageIgnore
* @return HasMany
*/
public function rules(): HasMany
{
return $this->hasMany(Rule::class);
}
/**
* @codeCoverageIgnore
* @return BelongsTo
@@ -131,4 +123,13 @@ class RuleGroup extends Model
{
return $this->belongsTo(User::class);
}
/**
* @codeCoverageIgnore
* @return HasMany
*/
public function rules(): HasMany
{
return $this->hasMany(Rule::class);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* RuleTrigger.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -31,16 +32,16 @@ use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\RuleTrigger
*
* @property int $id
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property int $rule_id
* @property string $trigger_type
* @property string $trigger_value
* @property int $order
* @property bool $active
* @property bool $stop_processing
* @property-read Rule $rule
* @property int $rule_id
* @property string $trigger_type
* @property string $trigger_value
* @property int $order
* @property bool $active
* @property bool $stop_processing
* @property-read Rule $rule
* @method static Builder|RuleTrigger newModelQuery()
* @method static Builder|RuleTrigger newQuery()
* @method static Builder|RuleTrigger query()

View File

@@ -1,4 +1,5 @@
<?php
/**
* Tag.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -37,25 +38,25 @@ 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 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-read int|null $transaction_journals_count
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|Tag newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Tag newQuery()
* @method static Builder|Tag onlyTrashed()
@@ -75,7 +76,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Tag withTrashed()
* @method static Builder|Tag withoutTrashed()
* @mixin Eloquent
* @property int|null $user_group_id
* @property int|null $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereUserGroupId($value)
*/
class Tag extends Model
@@ -105,7 +106,7 @@ class Tag extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return Tag
* @throws NotFoundHttpException
@@ -113,7 +114,7 @@ class Tag extends Model
public static function routeBinder(string $value): Tag
{
if (auth()->check()) {
$tagId = (int) $value;
$tagId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Tag $tag */
@@ -125,6 +126,15 @@ class Tag extends Model
throw new NotFoundHttpException();
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @codeCoverageIgnore
* @return MorphMany
@@ -151,13 +161,4 @@ class Tag extends Model
{
return $this->belongsToMany(TransactionJournal::class);
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Transaction.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -36,31 +37,31 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/**
* FireflyIII\Models\Transaction
*
* @property int $id
* @property int $id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\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 $modified
* @property string $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
* @property bool $reconciled
* @property int $account_id
* @property int $transaction_journal_id
* @property string|null $description
* @property int|null $transaction_currency_id
* @property string $modified
* @property string $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()
@@ -84,7 +85,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Query\Builder|Transaction withTrashed()
* @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed()
* @mixin Eloquent
* @property int $the_count
* @property int $the_count
*/
class Transaction extends Model
{
@@ -108,8 +109,17 @@ class Transaction extends Model
];
/** @var array Fields that can be filled */
protected $fillable
= ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier', 'transaction_currency_id', 'foreign_currency_id',
'foreign_amount', 'reconciled'];
= [
'account_id',
'transaction_journal_id',
'description',
'amount',
'identifier',
'transaction_currency_id',
'foreign_currency_id',
'foreign_amount',
'reconciled',
];
/** @var array Hidden from view */
protected $hidden = ['encrypted'];
@@ -162,8 +172,8 @@ class Transaction extends Model
*
* @codeCoverageIgnore
*
* @param Builder $query
* @param Carbon $date
* @param Builder $query
* @param Carbon $date
*/
public function scopeAfter(Builder $query, Carbon $date): void
{
@@ -176,8 +186,8 @@ class Transaction extends Model
/**
* Check if a table is joined.
*
* @param Builder $query
* @param string $table
* @param Builder $query
* @param string $table
*
* @return bool
* @codeCoverageIgnore
@@ -202,8 +212,8 @@ class Transaction extends Model
*
* @codeCoverageIgnore
*
* @param Builder $query
* @param Carbon $date
* @param Builder $query
* @param Carbon $date
*/
public function scopeBefore(Builder $query, Carbon $date): void
{
@@ -216,8 +226,8 @@ class Transaction extends Model
/**
* @codeCoverageIgnore
*
* @param Builder $query
* @param array $types
* @param Builder $query
* @param array $types
*/
public function scopeTransactionTypes(Builder $query, array $types): void
{
@@ -234,11 +244,11 @@ class Transaction extends Model
/**
* @codeCoverageIgnore
*
* @param mixed $value
* @param mixed $value
*/
public function setAmountAttribute($value): void
{
$this->attributes['amount'] = (string) $value;
$this->attributes['amount'] = (string)$value;
}
/**
@@ -267,7 +277,7 @@ class Transaction extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: fn ($value) => (string) $value,
get: fn ($value) => (string)$value,
);
}
@@ -279,7 +289,7 @@ class Transaction extends Model
protected function foreignAmount(): Attribute
{
return Attribute::make(
get: fn ($value) => (string) $value,
get: fn ($value) => (string)$value,
);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* TransactionCurrency.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -34,21 +35,21 @@ 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 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 int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property bool $enabled
* @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-read int|null $transaction_journals_count
* @property-read Collection|Transaction[] $transactions
* @property-read int|null $transactions_count
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newQuery()
* @method static Builder|TransactionCurrency onlyTrashed()
@@ -89,7 +90,7 @@ class TransactionCurrency extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return TransactionCurrency
* @throws NotFoundHttpException
@@ -97,7 +98,7 @@ class TransactionCurrency extends Model
public static function routeBinder(string $value): TransactionCurrency
{
if (auth()->check()) {
$currencyId = (int) $value;
$currencyId = (int)$value;
$currency = self::find($currencyId);
if (null !== $currency) {
return $currency;

View File

@@ -1,4 +1,5 @@
<?php
/**
* TransactionGroup.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -36,15 +37,15 @@ 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 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-read int|null $transaction_journals_count
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup newQuery()
* @method static Builder|TransactionGroup onlyTrashed()
@@ -58,7 +59,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|TransactionGroup withTrashed()
* @method static Builder|TransactionGroup withoutTrashed()
* @mixin Eloquent
* @property int|null $user_group_id
* @property int|null $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereUserGroupId($value)
*/
class TransactionGroup extends Model
@@ -86,7 +87,7 @@ class TransactionGroup extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return TransactionGroup
* @throws NotFoundHttpException
@@ -94,7 +95,7 @@ class TransactionGroup extends Model
public static function routeBinder(string $value): TransactionGroup
{
if (auth()->check()) {
$groupId = (int) $value;
$groupId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var TransactionGroup $group */
@@ -109,15 +110,6 @@ class TransactionGroup extends Model
throw new NotFoundHttpException();
}
/**
* @codeCoverageIgnore
* @return HasMany
*/
public function transactionJournals(): HasMany
{
return $this->hasMany(TransactionJournal::class);
}
/**
* @codeCoverageIgnore
* @return BelongsTo
@@ -126,4 +118,13 @@ class TransactionGroup extends Model
{
return $this->belongsTo(User::class);
}
/**
* @codeCoverageIgnore
* @return HasMany
*/
public function transactionJournals(): HasMany
{
return $this->hasMany(TransactionJournal::class);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* TransactionJournal.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -40,50 +41,50 @@ 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|null $transaction_group_id
* @property int|null $bill_id
* @property int|null $transaction_currency_id
* @property string $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 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|null $transaction_group_id
* @property int|null $bill_id
* @property int|null $transaction_currency_id
* @property string $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 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 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
* @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()
@@ -112,10 +113,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withTrashed()
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()
* @mixin Eloquent
* @property-read Collection|Location[] $locations
* @property-read int|null $locations_count
* @property int $the_count
* @property int|null $user_group_id
* @property-read Collection|Location[] $locations
* @property-read int|null $locations_count
* @property int $the_count
* @property int|null $user_group_id
* @method static EloquentBuilder|TransactionJournal whereUserGroupId($value)
*/
class TransactionJournal extends Model
@@ -145,15 +146,24 @@ class TransactionJournal extends Model
/** @var array Fields that can be filled */
protected $fillable
= ['user_id', 'transaction_type_id', 'bill_id', 'tag_count', 'transaction_currency_id', 'description', 'completed', 'order',
'date'];
= [
'user_id',
'transaction_type_id',
'bill_id',
'tag_count',
'transaction_currency_id',
'description',
'completed',
'order',
'date',
];
/** @var array Hidden from view */
protected $hidden = ['encrypted'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return TransactionJournal
* @throws NotFoundHttpException
@@ -161,7 +171,7 @@ class TransactionJournal extends Model
public static function routeBinder(string $value): TransactionJournal
{
if (auth()->check()) {
$journalId = (int) $value;
$journalId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var TransactionJournal $journal */
@@ -174,6 +184,15 @@ class TransactionJournal extends Model
throw new NotFoundHttpException();
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @codeCoverageIgnore
* @return MorphMany
@@ -262,8 +281,8 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param Carbon $date
* @param EloquentBuilder $query
* @param Carbon $date
*
* @return EloquentBuilder
*/
@@ -275,8 +294,8 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param Carbon $date
* @param EloquentBuilder $query
* @param Carbon $date
*
* @return EloquentBuilder
*/
@@ -288,8 +307,8 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param array $types
* @param EloquentBuilder $query
* @param array $types
*/
public function scopeTransactionTypes(EloquentBuilder $query, array $types): void
{
@@ -306,8 +325,8 @@ class TransactionJournal extends Model
*
* @codeCoverageIgnore
*
* @param Builder $query
* @param string $table
* @param Builder $query
* @param string $table
*
* @return bool
*/
@@ -388,13 +407,4 @@ class TransactionJournal extends Model
{
return $this->hasMany(Transaction::class);
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* TransactionJournalLink.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -34,20 +35,20 @@ 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 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 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-read string $inward
* @property-read string $outward
* @method static Builder|TransactionJournalLink newModelQuery()
* @method static Builder|TransactionJournalLink newQuery()
* @method static Builder|TransactionJournalLink query()
@@ -78,7 +79,7 @@ class TransactionJournalLink extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return TransactionJournalLink
*
@@ -87,7 +88,7 @@ class TransactionJournalLink extends Model
public static function routeBinder(string $value): TransactionJournalLink
{
if (auth()->check()) {
$linkId = (int) $value;
$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')

View File

@@ -1,4 +1,5 @@
<?php
/**
* TransactionJournalMeta.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -32,14 +33,14 @@ use Illuminate\Support\Carbon;
/**
* 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 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
* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransactionJournalMeta newQuery()
@@ -80,7 +81,7 @@ class TransactionJournalMeta extends Model
/**
* @codeCoverageIgnore
*
* @param mixed $value
* @param mixed $value
*
* @return mixed
*/
@@ -92,7 +93,7 @@ class TransactionJournalMeta extends Model
/**
* @codeCoverageIgnore
*
* @param mixed $value
* @param mixed $value
*/
public function setDataAttribute($value): void
{

View File

@@ -1,4 +1,5 @@
<?php
/**
* TransactionType.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -34,13 +35,13 @@ 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 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-read int|null $transaction_journals_count
* @method static \Illuminate\Database\Eloquent\Builder|TransactionType newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransactionType newQuery()
* @method static Builder|TransactionType onlyTrashed()
@@ -57,6 +58,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class TransactionType extends Model
{
use SoftDeletes;
public const DEPOSIT = 'Deposit';
public const INVALID = 'Invalid';
public const LIABILITY_CREDIT = 'Liability credit';
@@ -76,7 +78,7 @@ class TransactionType extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $type
* @param string $type
*
* @return TransactionType
* @throws NotFoundHttpException

View File

@@ -34,13 +34,13 @@ use Illuminate\Support\Carbon;
/**
* Class UserGroup
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property string $title
* @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-read int|null $group_memberships_count
* @method static Builder|UserGroup newModelQuery()
* @method static Builder|UserGroup newQuery()
* @method static Builder|UserGroup query()

View File

@@ -34,13 +34,13 @@ use Illuminate\Support\Carbon;
/**
* Class UserRole
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property string $title
* @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-read int|null $group_memberships_count
* @method static Builder|UserRole newModelQuery()
* @method static Builder|UserRole newQuery()
* @method static Builder|UserRole query()
@@ -57,9 +57,9 @@ class UserRole extends Model
public const CHANGE_REPETITIONS = 'change_reps';
public const CHANGE_RULES = 'change_rules';
public const CHANGE_TRANSACTIONS = 'change_tx';
public const MANAGE_WEBHOOKS = 'manage_webhooks';
public const MANAGE_CURRENCIES = 'manage_currencies';
public const FULL = 'full';
public const MANAGE_CURRENCIES = 'manage_currencies';
public const MANAGE_WEBHOOKS = 'manage_webhooks';
public const OWNER = 'owner';
public const READ_ONLY = 'ro';
public const VIEW_REPORTS = 'view_reports';

View File

@@ -40,19 +40,19 @@ 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 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
* @property-read int|null $webhook_messages_count
* @method static Builder|Webhook newModelQuery()
* @method static Builder|Webhook newQuery()
* @method static \Illuminate\Database\Query\Builder|Webhook onlyTrashed()
@@ -70,11 +70,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Query\Builder|Webhook withTrashed()
* @method static \Illuminate\Database\Query\Builder|Webhook withoutTrashed()
* @mixin Eloquent
* @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|null $user_group_id
* @property int|null $user_group_id
* @method static Builder|Webhook whereUserGroupId($value)
*/
class Webhook extends Model
@@ -90,10 +90,91 @@ class Webhook extends Model
];
protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'url', 'title', 'secret'];
/**
* @return array
*/
public static function getDeliveries(): array
{
$array = [];
$set = WebhookDelivery::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
/**
* @return array
*/
public static function getDeliveriesForValidation(): array
{
$array = [];
$set = WebhookDelivery::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* @return array
*/
public static function getResponses(): array
{
$array = [];
$set = WebhookResponse::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
/**
* @return array
*/
public static function getResponsesForValidation(): array
{
$array = [];
$set = WebhookResponse::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* @return array
*/
public static function getTriggers(): array
{
$array = [];
$set = WebhookTrigger::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
/**
* @return array
*/
public static function getTriggersForValidation(): array
{
$array = [];
$set = WebhookTrigger::cases();
foreach ($set as $item) {
$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
* @param string $value
*
* @return Webhook
* @throws NotFoundHttpException
@@ -101,7 +182,7 @@ class Webhook extends Model
public static function routeBinder(string $value): Webhook
{
if (auth()->check()) {
$webhookId = (int) $value;
$webhookId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Webhook $webhook */
@@ -130,85 +211,4 @@ class Webhook extends Model
{
return $this->hasMany(WebhookMessage::class);
}
/**
* @return array
*/
public static function getTriggers(): array
{
$array = [];
$set = WebhookTrigger::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
/**
* @return array
*/
public static function getTriggersForValidation(): array
{
$array = [];
$set = WebhookTrigger::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* @return array
*/
public static function getResponsesForValidation(): array
{
$array = [];
$set = WebhookResponse::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* @return array
*/
public static function getDeliveriesForValidation(): array
{
$array = [];
$set = WebhookDelivery::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* @return array
*/
public static function getResponses(): array
{
$array = [];
$set = WebhookResponse::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
/**
* @return array
*/
public static function getDeliveries(): array
{
$array = [];
$set = WebhookDelivery::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
}

View File

@@ -35,14 +35,14 @@ 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 $status_code
* @property string|null $logs
* @property string|null $response
* @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 $status_code
* @property string|null $logs
* @property string|null $response
* @property-read WebhookMessage $webhookMessage
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|WebhookAttempt newQuery()
@@ -67,7 +67,7 @@ class WebhookAttempt extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return WebhookAttempt
* @throws NotFoundHttpException
@@ -75,7 +75,7 @@ class WebhookAttempt extends Model
public static function routeBinder(string $value): WebhookAttempt
{
if (auth()->check()) {
$attemptId = (int) $value;
$attemptId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var WebhookAttempt $attempt */

View File

@@ -36,18 +36,18 @@ 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 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
* @method static Builder|WebhookMessage newModelQuery()
* @method static Builder|WebhookMessage newQuery()
* @method static Builder|WebhookMessage query()
@@ -64,7 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|WebhookMessage whereWebhookId($value)
* @mixin Eloquent
* @property-read Collection|WebhookAttempt[] $webhookAttempts
* @property-read int|null $webhook_attempts_count
* @property-read int|null $webhook_attempts_count
*/
class WebhookMessage extends Model
{
@@ -80,7 +80,7 @@ class WebhookMessage extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return WebhookMessage
* @throws NotFoundHttpException
@@ -88,7 +88,7 @@ class WebhookMessage extends Model
public static function routeBinder(string $value): WebhookMessage
{
if (auth()->check()) {
$messageId = (int) $value;
$messageId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var WebhookMessage $message */