Minor code cleanup.

This commit is contained in:
James Cole 2021-08-28 15:47:09 +02:00
parent 92f7a9c574
commit a14c9438ad
No known key found for this signature in database
GPG Key ID: BDE6667570EADBD5
34 changed files with 321 additions and 293 deletions

View File

@ -149,11 +149,12 @@ class Account extends Model
}
/**
* Get all of the tags for the post.
* @return BelongsTo
* @codeCoverageIgnore
*/
public function objectGroups()
public function accountType(): BelongsTo
{
return $this->morphToMany(ObjectGroup::class, 'object_groupable');
return $this->belongsTo(AccountType::class);
}
/**
@ -165,24 +166,6 @@ class Account extends Model
return $this->morphMany(Attachment::class, 'attachable');
}
/**
* @return HasMany
* @codeCoverageIgnore
*/
public function accountMeta(): HasMany
{
return $this->hasMany(AccountMeta::class);
}
/**
* @return BelongsTo
* @codeCoverageIgnore
*/
public function accountType(): BelongsTo
{
return $this->belongsTo(AccountType::class);
}
/**
* Get the account number.
*
@ -198,6 +181,15 @@ class Account extends Model
return $metaValue ? $metaValue->data : '';
}
/**
* @return HasMany
* @codeCoverageIgnore
*/
public function accountMeta(): HasMany
{
return $this->hasMany(AccountMeta::class);
}
/**
* @return string
* @codeCoverageIgnore
@ -231,6 +223,14 @@ class Account extends Model
return $this->morphMany(Note::class, 'noteable');
}
/**
* Get all of the tags for the post.
*/
public function objectGroups()
{
return $this->morphToMany(ObjectGroup::class, 'object_groupable');
}
/**
* @return HasMany
* @codeCoverageIgnore

View File

@ -27,6 +27,7 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
use JsonException;
/**
* Class AccountMeta
@ -79,7 +80,7 @@ class AccountMeta extends Model
* @param mixed $value
*
* @return mixed
* @throws \JsonException
* @throws JsonException
* @codeCoverageIgnore
*/
public function getDataAttribute($value)

View File

@ -28,6 +28,7 @@ use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\AccountType
*

View File

@ -22,27 +22,27 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\AvailableBudget
*
* @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 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 \Illuminate\Support\Carbon $start_date
* @property \Illuminate\Support\Carbon $end_date
* @property Carbon $start_date
* @property Carbon $end_date
* @property-read TransactionCurrency $transactionCurrency
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget newModelQuery()
@ -65,6 +65,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class AvailableBudget extends Model
{
use SoftDeletes;
/**
* The attributes that should be casted to native types.
*
@ -87,8 +88,8 @@ class AvailableBudget extends Model
*
* @param string $value
*
* @throws NotFoundHttpException
* @return AvailableBudget
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): AvailableBudget
{

View File

@ -22,23 +22,23 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\BudgetLimit
*
* @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 int $budget_id
* @property int|null $transaction_currency_id
* @property \Illuminate\Support\Carbon $start_date
* @property \Illuminate\Support\Carbon|null $end_date
* @property Carbon $start_date
* @property Carbon|null $end_date
* @property string $amount
* @property string $spent
* @property string|null $period

View File

@ -96,8 +96,8 @@ class Category extends Model
*
* @param string $value
*
* @throws NotFoundHttpException
* @return Category
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Category
{
@ -114,14 +114,6 @@ class Category extends Model
throw new NotFoundHttpException;
}
/**
* @codeCoverageIgnore
* @return BelongsToMany
*/
public function transactionJournals(): BelongsToMany
{
return $this->belongsToMany(TransactionJournal::class, 'category_transaction_journal', 'category_id');
}
/**
* @codeCoverageIgnore
* @return MorphMany
@ -140,6 +132,15 @@ class Category extends Model
return $this->morphMany(Note::class, 'noteable');
}
/**
* @codeCoverageIgnore
* @return BelongsToMany
*/
public function transactionJournals(): BelongsToMany
{
return $this->belongsToMany(TransactionJournal::class, 'category_transaction_journal', 'category_id');
}
/**
* @codeCoverageIgnore
* @return BelongsToMany

View File

@ -71,6 +71,7 @@ class Configuration extends Model
/**
* See reference nr. 17
*
* @codeCoverageIgnore
*
* @param mixed $value

View File

@ -22,24 +22,24 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
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;
/**
* FireflyIII\Models\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 TransactionCurrency $fromCurrency

View File

@ -22,21 +22,22 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\LinkType
*
* @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 Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property string $name
* @property string $outward
* @property string $inward
@ -63,6 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class LinkType extends Model
{
use SoftDeletes;
/**
* The attributes that should be casted to native types.
*
@ -84,9 +86,9 @@ class LinkType extends Model
*
* @param string $value
*
* @throws NotFoundHttpException
* @return LinkType
*
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): LinkType
{

View File

@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
@ -30,6 +31,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\Location
*

View File

@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
@ -32,6 +33,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\ObjectGroup
*
@ -63,8 +65,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class ObjectGroup extends Model
{
protected $fillable = ['title', 'order', 'user_id'];
/**
* The attributes that should be casted to native types.
*
@ -77,38 +77,15 @@ class ObjectGroup extends Model
'user_id' => 'integer',
'deleted_at' => 'datetime',
];
/**
* @return MorphToMany
*/
public function piggyBanks()
{
return $this->morphedByMany(PiggyBank::class, 'object_groupable');
}
/**
* @return MorphToMany
*/
public function bills()
{
return $this->morphedByMany(Bill::class, 'object_groupable');
}
/**
* @return MorphToMany
*/
public function accounts()
{
return $this->morphedByMany(Account::class, 'object_groupable');
}
protected $fillable = ['title', 'order', 'user_id'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @throws NotFoundHttpException
* @return ObjectGroup
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): ObjectGroup
{
@ -124,6 +101,30 @@ class ObjectGroup extends Model
throw new NotFoundHttpException;
}
/**
* @return MorphToMany
*/
public function accounts()
{
return $this->morphedByMany(Account::class, 'object_groupable');
}
/**
* @return MorphToMany
*/
public function bills()
{
return $this->morphedByMany(Bill::class, 'object_groupable');
}
/**
* @return MorphToMany
*/
public function piggyBanks()
{
return $this->morphedByMany(PiggyBank::class, 'object_groupable');
}
/**
* @return BelongsTo
* @codeCoverageIgnore

View File

@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@ -31,19 +30,21 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\PiggyBank
*
* @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 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 \Illuminate\Support\Carbon|null $startdate
* @property \Illuminate\Support\Carbon|null $targetdate
* @property Carbon|null $startdate
* @property Carbon|null $targetdate
* @property int $order
* @property bool $active
* @property bool $encrypted
@ -108,8 +109,8 @@ class PiggyBank extends Model
*
* @param string $value
*
* @throws NotFoundHttpException
* @return PiggyBank
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): PiggyBank
{
@ -126,11 +127,12 @@ class PiggyBank extends Model
}
/**
* Get all of the tags for the post.
* @codeCoverageIgnore
* @return BelongsTo
*/
public function objectGroups()
public function account(): BelongsTo
{
return $this->morphToMany(ObjectGroup::class, 'object_groupable');
return $this->belongsTo(Account::class);
}
/**
@ -142,15 +144,6 @@ class PiggyBank extends Model
return $this->morphMany(Attachment::class, 'attachable');
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function account(): BelongsTo
{
return $this->belongsTo(Account::class);
}
/**
* @codeCoverageIgnore
* Get all of the piggy bank's notes.
@ -160,6 +153,14 @@ class PiggyBank extends Model
return $this->morphMany(Note::class, 'noteable');
}
/**
* Get all of the tags for the post.
*/
public function objectGroups()
{
return $this->morphToMany(ObjectGroup::class, 'object_groupable');
}
/**
* @codeCoverageIgnore
* @return HasMany

View File

@ -22,20 +22,21 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\PiggyBankEvent
*
* @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 int $piggy_bank_id
* @property int|null $transaction_journal_id
* @property \Illuminate\Support\Carbon $date
* @property Carbon $date
* @property string $amount
* @property PiggyBank $piggyBank
* @property-read TransactionJournal|null $transactionJournal

View File

@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Collection;
@ -89,6 +90,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Recurrence extends Model
{
use SoftDeletes;
/**
* The attributes that should be casted to native types.
*
@ -120,8 +122,8 @@ class Recurrence extends Model
*
* @param string $value
*
* @throws NotFoundHttpException
* @return Recurrence
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Recurrence
{
@ -138,6 +140,15 @@ class Recurrence extends Model
throw new NotFoundHttpException;
}
/**
* @codeCoverageIgnore
* @return MorphMany
*/
public function attachments(): MorphMany
{
return $this->morphMany(Attachment::class, 'attachable');
}
/**
* @codeCoverageIgnore
* Get all of the notes.
@ -183,15 +194,6 @@ class Recurrence extends Model
return $this->belongsTo(TransactionCurrency::class);
}
/**
* @codeCoverageIgnore
* @return MorphMany
*/
public function attachments(): MorphMany
{
return $this->morphMany(Attachment::class, 'attachable');
}
/**
* @codeCoverageIgnore
* @return BelongsTo

View File

@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -58,6 +59,7 @@ use Illuminate\Support\Carbon;
class RecurrenceMeta extends Model
{
use SoftDeletes;
/**
* The attributes that should be casted to native types.
*

View File

@ -22,20 +22,21 @@
declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\RecurrenceRepetition
*
* @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 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
@ -70,6 +71,7 @@ class RecurrenceRepetition extends Model
/** @var int */
public const WEEKEND_TO_MONDAY = 4;
use SoftDeletes;
/**
* The attributes that should be casted to native types.
*

View File

@ -22,14 +22,15 @@
declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
/**
* FireflyIII\Models\RecurrenceTransaction
@ -49,7 +50,7 @@ use Illuminate\Support\Collection;
* @property-read Account $destinationAccount
* @property-read TransactionCurrency|null $foreignCurrency
* @property-read Recurrence $recurrence
* @property-read \Illuminate\Database\Eloquent\Collection|RecurrenceTransactionMeta[] $recurrenceTransactionMeta
* @property-read Collection|RecurrenceTransactionMeta[] $recurrenceTransactionMeta
* @property-read int|null $recurrence_transaction_meta_count
* @property-read Account $sourceAccount
* @property-read TransactionCurrency $transactionCurrency
@ -79,6 +80,7 @@ use Illuminate\Support\Collection;
class RecurrenceTransaction extends Model
{
use SoftDeletes;
/**
* The attributes that should be casted to native types.
*
@ -153,6 +155,7 @@ class RecurrenceTransaction extends Model
{
return $this->belongsTo(TransactionCurrency::class);
}
/**
* @codeCoverageIgnore
* @return BelongsTo

View File

@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -58,6 +59,7 @@ use Illuminate\Support\Carbon;
class RecurrenceTransactionMeta extends Model
{
use SoftDeletes;
/**
* The attributes that should be casted to native types.
*

View File

@ -22,18 +22,18 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\RuleAction
*
* @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 int $rule_id
* @property string $action_type
* @property string $action_value

View File

@ -22,30 +22,31 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Collection;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\RuleGroup
*
* @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 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 \Illuminate\Database\Eloquent\Collection|Rule[] $rules
* @property Collection|Rule[] $rules
* @property-read int|null $rules_count
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newModelQuery()
@ -69,6 +70,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class RuleGroup extends Model
{
use SoftDeletes;
/**
* The attributes that should be casted to native types.
*
@ -92,8 +94,8 @@ class RuleGroup extends Model
*
* @param string $value
*
* @throws NotFoundHttpException
* @return RuleGroup
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): RuleGroup
{

View File

@ -22,18 +22,18 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\RuleTrigger
*
* @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 int $rule_id
* @property string $trigger_type
* @property string $trigger_value

View File

@ -52,16 +52,16 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property string|null $foreign_amount
* @property int|null $foreign_currency_id
* @property int $identifier
* @property-read \FireflyIII\Models\Account $account
* @property-read Collection|\FireflyIII\Models\Budget[] $budgets
* @property-read Account $account
* @property-read Collection|Budget[] $budgets
* @property-read int|null $budgets_count
* @property-read Collection|\FireflyIII\Models\Category[] $categories
* @property-read Collection|Category[] $categories
* @property-read int|null $categories_count
* @property-read \FireflyIII\Models\TransactionCurrency|null $foreignCurrency
* @property-read \FireflyIII\Models\TransactionCurrency|null $transactionCurrency
* @property-read \FireflyIII\Models\TransactionJournal $transactionJournal
* @method static Builder|Transaction after(\Carbon\Carbon $date)
* @method static Builder|Transaction before(\Carbon\Carbon $date)
* @property-read TransactionCurrency|null $foreignCurrency
* @property-read TransactionCurrency|null $transactionCurrency
* @property-read TransactionJournal $transactionJournal
* @method static Builder|Transaction after(Carbon $date)
* @method static Builder|Transaction before(Carbon $date)
* @method static Builder|Transaction newModelQuery()
* @method static Builder|Transaction newQuery()
* @method static \Illuminate\Database\Query\Builder|Transaction onlyTrashed()
@ -88,6 +88,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class Transaction extends Model
{
use SoftDeletes, HasFactory;
/**
* The attributes that should be casted to native types.
*
@ -110,30 +111,6 @@ class Transaction extends Model
/** @var array Hidden from view */
protected $hidden = ['encrypted'];
/**
* Check if a table is joined.
*
* @param Builder $query
* @param string $table
*
* @return bool
* @codeCoverageIgnore
*/
public static function isJoined(Builder $query, string $table): bool
{
$joins = $query->getQuery()->joins;
if (null === $joins) {
return false;
}
foreach ($joins as $join) {
if ($join->table === $table) {
return true;
}
}
return false;
}
/**
* Get the account this object belongs to.
*
@ -194,6 +171,30 @@ class Transaction extends Model
$query->where('transaction_journals.date', '>=', $date->format('Y-m-d 00:00:00'));
}
/**
* Check if a table is joined.
*
* @param Builder $query
* @param string $table
*
* @return bool
* @codeCoverageIgnore
*/
public static function isJoined(Builder $query, string $table): bool
{
$joins = $query->getQuery()->joins;
if (null === $joins) {
return false;
}
foreach ($joins as $join) {
if ($join->table === $table) {
return true;
}
}
return false;
}
/**
* Check for transactions BEFORE the specified date.
*

View File

@ -22,21 +22,22 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\TransactionCurrency
*
* @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 Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property bool $enabled
* @property string $code
* @property string $name
@ -90,8 +91,8 @@ class TransactionCurrency extends Model
*
* @param string $value
*
* @throws NotFoundHttpException
* @return TransactionCurrency
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): TransactionCurrency
{

View File

@ -32,6 +32,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\TransactionGroup
*
@ -85,8 +86,8 @@ class TransactionGroup extends Model
*
* @param string $value
*
* @throws NotFoundHttpException
* @return TransactionGroup
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): TransactionGroup
{

View File

@ -22,21 +22,21 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\TransactionJournalLink
*
* @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 int $link_type_id
* @property int $source_id
* @property int $destination_id
@ -80,9 +80,9 @@ class TransactionJournalLink extends Model
*
* @param string $value
*
* @throws NotFoundHttpException
* @return TransactionJournalLink
*
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): TransactionJournalLink
{

View File

@ -60,6 +60,7 @@ use Illuminate\Support\Carbon;
class TransactionJournalMeta extends Model
{
use SoftDeletes;
/**
* The attributes that should be casted to native types.
*

View File

@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
@ -88,9 +89,6 @@ class Webhook extends Model
// delivery
public const DELIVERY_JSON = 300;
protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'url', 'title', 'secret'];
protected $casts
= [
'active' => 'boolean',
@ -98,6 +96,7 @@ class Webhook extends Model
'response' => 'integer',
'delivery' => 'integer',
];
protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'url', 'title', 'secret'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).

View File

@ -64,15 +64,6 @@ class WebhookAttempt extends Model
{
use SoftDeletes;
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function webhookMessage(): BelongsTo
{
return $this->belongsTo(WebhookMessage::class);
}
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
@ -95,4 +86,13 @@ class WebhookAttempt extends Model
}
throw new NotFoundHttpException;
}
/**
* @codeCoverageIgnore
* @return BelongsTo
*/
public function webhookMessage(): BelongsTo
{
return $this->belongsTo(WebhookMessage::class);
}
}