Various code cleanup.

This commit is contained in:
James Cole
2018-08-04 17:30:06 +02:00
parent 5af026674f
commit f0d3ca5d53
88 changed files with 552 additions and 311 deletions

View File

@@ -75,18 +75,20 @@ class Account extends Model
'active' => 'boolean',
'encrypted' => 'boolean',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
/** @var array */
/** @var array Hidden from view */
protected $hidden = ['encrypted'];
/** @var bool */
private $joinedAccountTypes;
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return Account
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Account
{

View File

@@ -44,11 +44,9 @@ class AccountMeta extends Model
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['account_id', 'name', 'data'];
/**
* @var string
*/
/** @var string The table to store the data in */
protected $table = 'account_meta';
/**

View File

@@ -35,25 +35,43 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
*/
class AccountType extends Model
{
/** @var string */
public const DEFAULT = 'Default account';
/** @var string */
public const CASH = 'Cash account';
/** @var string */
public const ASSET = 'Asset account';
/** @var string */
public const EXPENSE = 'Expense account';
/** @var string */
public const REVENUE = 'Revenue account';
/** @var string */
public const INITIAL_BALANCE = 'Initial balance account';
/** @var string */
public const BENEFICIARY = 'Beneficiary account';
/** @var string */
public const IMPORT = 'Import account';
/** @var string */
public const RECONCILIATION = 'Reconciliation account';
/** @var string */
public const LOAN = 'Loan';
/** @var string */
public const DEBT = 'Debt';
/** @var string */
public const MORTGAGE = 'Mortgage';
/** @var string */
public const CREDITCARD = 'Credit card';
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['type'];
/**

View File

@@ -66,14 +66,16 @@ class Attachment extends Model
'deleted_at' => 'datetime',
'uploaded' => 'boolean',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['attachable_id', 'attachable_type', 'user_id', 'md5', 'filename', 'mime', 'title', 'description', 'size', 'uploaded'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return Attachment
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Attachment
{

View File

@@ -58,14 +58,16 @@ class AvailableBudget extends Model
'start_date' => 'date',
'end_date' => 'date',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['user_id', 'transaction_currency_id', 'amount', 'start_date', 'end_date'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return AvailableBudget
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): AvailableBudget
{
@@ -84,7 +86,7 @@ class AvailableBudget extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function transactionCurrency(): BelongsTo
{

View File

@@ -77,22 +77,21 @@ class Bill extends Model
'name_encrypted' => 'boolean',
'match_encrypted' => 'boolean',
];
/**
* @var array
*/
/** @var array Fields that can be filled */
protected $fillable
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
'automatch', 'active', 'transaction_currency_id'];
/**
* @var array
*/
/** @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
*
* @return Bill
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Bill
{

View File

@@ -26,6 +26,8 @@ use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -58,16 +60,18 @@ class Budget extends Model
'active' => 'boolean',
'encrypted' => 'boolean',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['user_id', 'name', 'active'];
/** @var array */
/** @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
*
* @return Budget
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Budget
{
@@ -86,9 +90,9 @@ class Budget extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return HasMany
*/
public function budgetlimits(): \Illuminate\Database\Eloquent\Relations\HasMany
public function budgetlimits(): HasMany
{
return $this->hasMany(BudgetLimit::class);
}
@@ -126,18 +130,18 @@ class Budget extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
public function transactionJournals(): BelongsToMany
{
return $this->belongsToMany(TransactionJournal::class, 'budget_transaction_journal', 'budget_id');
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function transactions(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
public function transactions(): BelongsToMany
{
return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id');
}

View File

@@ -54,13 +54,17 @@ class BudgetLimit extends Model
'start_date' => 'date',
'end_date' => 'date',
];
/** @var array Fields that can be filled */
protected $fillable = ['budget_id', 'start_date', 'end_date', 'amount'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return mixed
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): BudgetLimit
{

View File

@@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Models;
@@ -27,6 +28,7 @@ use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -55,16 +57,18 @@ class Category extends Model
'deleted_at' => 'datetime',
'encrypted' => 'boolean',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['user_id', 'name'];
/** @var array */
/** @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
*
* @return Category
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Category
{
@@ -114,18 +118,18 @@ class Category extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
public function transactionJournals(): BelongsToMany
{
return $this->belongsToMany(TransactionJournal::class, 'category_transaction_journal', 'category_id');
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function transactions(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
public function transactions(): BelongsToMany
{
return $this->belongsToMany(Transaction::class, 'category_transaction', 'category_id');
}

View File

@@ -44,10 +44,9 @@ class Configuration extends Model
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
/**
* @var string
*/
/** @var string The table to store the data in */
protected $table = 'configuration';
/**

View File

@@ -43,8 +43,16 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
*/
class CurrencyExchangeRate extends Model
{
/** @var array */
protected $dates = ['date'];
/** @var array Convert these fields to other data types */
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'user_id' => 'int',
'from_currency_id' => 'int',
'to_currency_id' => 'int',
'date' => 'datetime',
];
/**
* @codeCoverageIgnore

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
@@ -37,7 +38,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class ExportJob extends Model
{
/** @var array */
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'created_at' => 'datetime',
@@ -45,6 +50,8 @@ class ExportJob extends Model
];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return ExportJob
@@ -67,9 +74,12 @@ class ExportJob extends Model
}
/**
* @codeCoverageIgnore
* Change the status of this export job.
*
* @param $status
*
* @deprecated
* @codeCoverageIgnore
*/
public function change($status): void
{
@@ -78,10 +88,13 @@ class ExportJob extends Model
}
/**
* Returns the user this objects belongs to.
*
*
* @return BelongsTo
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
@@ -61,10 +62,12 @@ class ImportJob extends Model
'transactions' => 'array',
'errors' => 'array',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['key', 'user_id', 'file_type', 'provider', 'status', 'stage', 'configuration', 'extended_status', 'transactions', 'errors'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param $value
*
* @return mixed
@@ -97,18 +100,18 @@ class ImportJob extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function tag(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function tag(): BelongsTo
{
return $this->belongsTo(Tag::class);
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -55,10 +56,12 @@ class LinkType extends Model
'editable' => 'boolean',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['name', 'inward', 'outward', 'editable'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param $value
*
* @return LinkType
@@ -79,9 +82,9 @@ class LinkType extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return HasMany
*/
public function transactionJournalLinks(): \Illuminate\Database\Eloquent\Relations\HasMany
public function transactionJournalLinks(): HasMany
{
return $this->hasMany(TransactionJournalLink::class);
}

View File

@@ -51,7 +51,7 @@ class Note extends Model
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['title', 'text', 'noteable_id', 'noteable_type'];
/**

View File

@@ -26,6 +26,7 @@ use Carbon\Carbon;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -67,18 +68,18 @@ class PiggyBank extends Model
'active' => 'boolean',
'encrypted' => 'boolean',
];
/** @var array */
protected $dates = ['startdate', 'targetdate'];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate', 'active'];
/** @var array */
/** @var array Hidden from view */
protected $hidden = ['targetamount_encrypted', 'encrypted'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return PiggyBank
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): PiggyBank
{
@@ -96,7 +97,7 @@ class PiggyBank extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function account(): BelongsTo
{
@@ -131,18 +132,18 @@ class PiggyBank extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return HasMany
*/
public function piggyBankEvents(): \Illuminate\Database\Eloquent\Relations\HasMany
public function piggyBankEvents(): HasMany
{
return $this->hasMany(PiggyBankEvent::class);
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return HasMany
*/
public function piggyBankRepetitions(): \Illuminate\Database\Eloquent\Relations\HasMany
public function piggyBankRepetitions(): HasMany
{
return $this->hasMany(PiggyBankRepetition::class);
}

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* Class PiggyBankEvent.
@@ -47,22 +48,16 @@ class PiggyBankEvent extends Model
'updated_at' => 'datetime',
'date' => 'date',
];
/** @var array */
protected $dates = ['date'];
/**
* @var array
*/
/** @var array Fields that can be filled */
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
/**
* @var array
*/
/** @var array Hidden from view */
protected $hidden = ['amount_encrypted'];
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function piggyBank(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function piggyBank(): BelongsTo
{
return $this->belongsTo(PiggyBank::class);
}
@@ -79,9 +74,9 @@ class PiggyBankEvent extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function transactionJournal(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function transactionJournal(): BelongsTo
{
return $this->belongsTo(TransactionJournal::class);
}

View File

@@ -25,6 +25,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* Class PiggyBankRepetition.
@@ -44,20 +45,17 @@ class PiggyBankRepetition extends Model
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
'startdate' => 'date',
'targetdate' => 'date',
];
/** @var array */
protected $dates = ['startdate', 'targetdate'];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function piggyBank(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function piggyBank(): BelongsTo
{
return $this->belongsTo(PiggyBank::class);
}

View File

@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -55,14 +56,16 @@ class Preference extends Model
'updated_at' => 'datetime',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['user_id', 'data', 'name'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return Preference
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Preference
{
@@ -129,9 +132,9 @@ class Preference extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}

View File

@@ -82,17 +82,19 @@ class Recurrence extends Model
'active' => 'bool',
'apply_rules' => 'bool',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable
= ['user_id', 'transaction_type_id', 'title', 'description', 'first_date', 'repeat_until', 'latest_date', 'repetitions', 'apply_rules', 'active'];
/** @var string */
/** @var string The table to store the data in */
protected $table = 'recurrences';
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return Recurrence
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Recurrence
{

View File

@@ -37,7 +37,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class RecurrenceMeta extends Model
{
use SoftDeletes;
/** @var array */
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'created_at' => 'datetime',
@@ -46,9 +50,9 @@ class RecurrenceMeta extends Model
'name' => 'string',
'value' => 'string',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['recurrence_id', 'name', 'value'];
/** @var string */
/** @var string The table to store the data in */
protected $table = 'recurrences_meta';
/**

View File

@@ -51,7 +51,11 @@ class RecurrenceRepetition extends Model
/** @var int */
public const WEEKEND_TO_MONDAY = 4;
use SoftDeletes;
/** @var array */
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'created_at' => 'datetime',
@@ -62,8 +66,9 @@ class RecurrenceRepetition extends Model
'repetition_skip' => 'int',
'weekend' => 'int',
];
/** @var array Fields that can be filled */
protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip'];
/** @var string */
/** @var string The table to store the data in */
protected $table = 'recurrences_repetitions';
/**

View File

@@ -51,7 +51,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class RecurrenceTransaction extends Model
{
use SoftDeletes;
/** @var array */
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'created_at' => 'datetime',
@@ -61,16 +65,16 @@ class RecurrenceTransaction extends Model
'foreign_amount' => 'string',
'description' => 'string',
];
/** @var array */
/** @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'];
/** @var string */
/** @var string The table to store the data in */
protected $table = 'recurrences_transactions';
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function destinationAccount(): BelongsTo
{
@@ -106,7 +110,7 @@ class RecurrenceTransaction extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function sourceAccount(): BelongsTo
{

View File

@@ -37,7 +37,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class RecurrenceTransactionMeta extends Model
{
use SoftDeletes;
/** @var array */
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'created_at' => 'datetime',
@@ -46,8 +50,9 @@ class RecurrenceTransactionMeta extends Model
'name' => 'string',
'value' => 'string',
];
/** @var array Fields that can be filled */
protected $fillable = ['rt_id', 'name', 'value'];
/** @var string */
/** @var string The table to store the data in */
protected $table = 'rt_meta';
/**

View File

@@ -45,14 +45,12 @@ class Role extends Model
'updated_at' => 'datetime',
];
/**
* @var array
*/
/** @var array Fields that can be filled */
protected $fillable = ['name', 'display_name', 'description'];
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function users(): BelongsToMany
{

View File

@@ -70,14 +70,16 @@ class Rule extends Model
'id' => 'int',
'strict' => 'boolean',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['rule_group_id', 'order', 'active', 'title', 'description', 'user_id', 'strict'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return Rule
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Rule
{

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* Class RuleAction.
@@ -54,14 +55,14 @@ class RuleAction extends Model
'stop_processing' => 'boolean',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['rule_id', 'action_type', 'action_value', 'order', 'active', 'stop_processing'];
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function rule(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function rule(): BelongsTo
{
return $this->belongsTo(Rule::class);
}

View File

@@ -25,6 +25,8 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -60,16 +62,16 @@ class RuleGroup extends Model
'order' => 'int',
];
/**
* @var array
*/
/** @var array Fields that can be filled */
protected $fillable = ['user_id', 'order', 'title', 'description', 'active'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return RuleGroup
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): RuleGroup
{
@@ -88,18 +90,18 @@ class RuleGroup extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return HasMany
*/
public function rules(): \Illuminate\Database\Eloquent\Relations\HasMany
public function rules(): HasMany
{
return $this->hasMany(Rule::class);
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* Class RuleTrigger.
@@ -53,14 +54,14 @@ class RuleTrigger extends Model
'stop_processing' => 'boolean',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['rule_id', 'trigger_type', 'trigger_value', 'order', 'active', 'stop_processing'];
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function rule(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function rule(): BelongsTo
{
return $this->belongsTo(Rule::class);
}

View File

@@ -25,6 +25,8 @@ namespace FireflyIII\Models;
use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -60,16 +62,16 @@ class Tag extends Model
'date' => 'date',
'zoomLevel' => 'int',
];
/** @var array */
protected $dates = ['date'];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return Tag
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Tag
{
@@ -146,18 +148,18 @@ class Tag extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
public function transactionJournals(): BelongsToMany
{
return $this->belongsToMany(TransactionJournal::class);
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}

View File

@@ -27,6 +27,7 @@ use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -100,6 +101,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class Transaction extends Model
{
use SoftDeletes;
/**
* The attributes that should be casted to native types.
*
@@ -115,24 +117,23 @@ class Transaction extends Model
'bill_name_encrypted' => 'boolean',
'reconciled' => 'boolean',
];
/**
* @var array
*/
/** @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'];
/**
* @var array
*/
/** @var array Hidden from view */
protected $hidden = ['encrypted'];
/**
* @codeCoverageIgnore
* Check if a table is joined.
*
*
*
* @param Builder $query
* @param string $table
*
* @return bool
* @codeCoverageIgnore
*/
public static function isJoined(Builder $query, string $table): bool
{
@@ -150,10 +151,12 @@ class Transaction extends Model
}
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return Transaction
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Transaction
{
@@ -171,11 +174,12 @@ class Transaction extends Model
throw new NotFoundHttpException;
}
use SoftDeletes;
/**
* Get the account this object belongs to.
*
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function account(): BelongsTo
{
@@ -183,26 +187,32 @@ class Transaction extends Model
}
/**
* Get the budget(s) this object belongs to.
*
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function budgets(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
public function budgets(): BelongsToMany
{
return $this->belongsToMany(Budget::class);
}
/**
* Get the category(ies) this object belongs to.
*
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function categories(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
public function categories(): BelongsToMany
{
return $this->belongsToMany(Category::class);
}
/**
* Get the currency this object belongs to.
*
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function foreignCurrency(): BelongsTo
{
@@ -210,6 +220,8 @@ class Transaction extends Model
}
/**
* Check for transactions AFTER a specified date.
*
* @codeCoverageIgnore
*
* @param Builder $query
@@ -224,6 +236,7 @@ class Transaction extends Model
}
/**
* Check for transactions BEFORE the specified date.
* @codeCoverageIgnore
*
* @param Builder $query

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -52,16 +53,16 @@ class TransactionCurrency extends Model
'deleted_at' => 'datetime',
'decimal_places' => 'int',
];
/** @var array */
protected $dates = ['date'];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['name', 'code', 'symbol', 'decimal_places'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return TransactionCurrency
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): TransactionCurrency
{
@@ -77,9 +78,9 @@ class TransactionCurrency extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return HasMany
*/
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\HasMany
public function transactionJournals(): HasMany
{
return $this->hasMany(TransactionJournal::class);
}

View File

@@ -28,6 +28,7 @@ use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
@@ -91,15 +92,17 @@ class TransactionJournal extends Model
'completed' => 'boolean',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable
= ['user_id', 'transaction_type_id', 'bill_id', 'interest_date', 'book_date', 'process_date',
'transaction_currency_id', 'description', 'completed',
'date', 'rent_date', 'encrypted', 'tag_count',];
/** @var array */
/** @var array Hidden from view */
protected $hidden = ['encrypted'];
/**
* Checks if tables are joined.
*
* @param Builder $query
* @param string $table
*
@@ -121,10 +124,12 @@ class TransactionJournal extends Model
}
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return TransactionJournal
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): TransactionJournal
{
@@ -154,16 +159,16 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function bill(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function bill(): BelongsTo
{
return $this->belongsTo(Bill::class);
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function budgets(): BelongsToMany
{
@@ -172,7 +177,7 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function categories(): BelongsToMany
{
@@ -259,7 +264,7 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return HasMany
*/
public function piggyBankEvents(): HasMany
{
@@ -333,7 +338,7 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return BelongsToMany
*/
public function tags(): BelongsToMany
{
@@ -342,9 +347,9 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function transactionCurrency(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function transactionCurrency(): BelongsTo
{
return $this->belongsTo(TransactionCurrency::class);
}
@@ -360,9 +365,9 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function transactionType(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function transactionType(): BelongsTo
{
return $this->belongsTo(TransactionType::class);
}
@@ -378,9 +383,9 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}

View File

@@ -45,12 +45,23 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class TransactionJournalLink extends Model
{
/**
* @var string
*/
/** @var string The table to store the data in */
protected $table = 'journal_links';
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return mixed
@@ -76,7 +87,7 @@ class TransactionJournalLink extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function destination(): BelongsTo
{
@@ -101,7 +112,7 @@ class TransactionJournalLink extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function linkType(): BelongsTo
{
@@ -136,7 +147,7 @@ class TransactionJournalLink extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function source(): BelongsTo
{

View File

@@ -49,9 +49,9 @@ class TransactionJournalMeta extends Model
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash'];
/** @var string */
/** @var string The table to store the data in */
protected $table = 'journal_meta';
/**
@@ -80,7 +80,7 @@ class TransactionJournalMeta extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function transactionJournal(): BelongsTo
{

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -67,14 +68,16 @@ class TransactionType extends Model
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
/** @var array */
/** @var array Fields that can be filled */
protected $fillable = ['type'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $type
*
* @return Model|null|static
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws NotFoundHttpException
*/
public static function routeBinder(string $type): TransactionType
{
@@ -126,9 +129,9 @@ class TransactionType extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return HasMany
*/
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\HasMany
public function transactionJournals(): HasMany
{
return $this->hasMany(TransactionJournal::class);
}