From f949d2476b255115df9ed7e6eb49830346a43b94 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 15 Jan 2016 22:32:21 +0100 Subject: [PATCH] Move from getDates to array dates. --- app/Models/Account.php | 14 +++----------- app/Models/AccountMeta.php | 11 ++--------- app/Models/AccountType.php | 11 ++--------- app/Models/Bill.php | 14 +++----------- app/Models/Budget.php | 13 +++---------- app/Models/BudgetLimit.php | 9 +-------- app/Models/Category.php | 10 +--------- app/Models/Component.php | 21 ++------------------- app/Models/LimitRepetition.php | 9 +-------- app/Models/PiggyBank.php | 11 ++--------- app/Models/PiggyBankEvent.php | 10 +--------- app/Models/PiggyBankRepetition.php | 9 +-------- app/Models/Preference.php | 10 +--------- app/Models/Tag.php | 12 ++---------- app/Models/Transaction.php | 12 +++--------- app/Models/TransactionCurrency.php | 9 +-------- app/Models/TransactionGroup.php | 8 +------- app/Models/TransactionType.php | 8 +------- 18 files changed, 31 insertions(+), 170 deletions(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index 7545b3b9e1..ecfc6825ea 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -5,10 +5,10 @@ use Crypt; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\JoinClause; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Watson\Validating\ValidatingTrait; -use Illuminate\Database\Query\Builder; /** * FireflyIII\Models\Account @@ -41,12 +41,13 @@ class Account extends Model protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban']; protected $hidden = ['virtual_balance_encrypted', 'encrypted']; + protected $dates = ['created_at', 'updated_at', 'deleted_at']; protected $rules = [ 'user_id' => 'required|exists:users,id', 'account_type_id' => 'required|exists:account_types,id', 'name' => 'required', - 'active' => 'required|boolean' + 'active' => 'required|boolean', ]; /** @@ -126,15 +127,6 @@ class Account extends Model return $this->belongsTo('FireflyIII\Models\AccountType'); } - /** - * @codeCoverageIgnore - * @return string[] - */ - public function getDates() - { - return ['created_at', 'updated_at', 'deleted_at']; - } - /** * @codeCoverageIgnore * diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php index aab45415f6..652f6a116e 100644 --- a/app/Models/AccountMeta.php +++ b/app/Models/AccountMeta.php @@ -24,9 +24,10 @@ class AccountMeta extends Model = [ 'account_id' => 'required|exists:accounts,id', 'name' => 'required|between:1,100', - 'data' => 'required' + 'data' => 'required', ]; protected $table = 'account_meta'; + protected $dates = ['created_at', 'updated_at']; /** * @@ -48,14 +49,6 @@ class AccountMeta extends Model return json_decode($value); } - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at']; - } - /** * @param $value */ diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php index 55f1e1f720..817d488b14 100644 --- a/app/Models/AccountType.php +++ b/app/Models/AccountType.php @@ -17,6 +17,8 @@ use Illuminate\Database\Eloquent\Model; class AccountType extends Model { + protected $dates = ['created_at', 'updated_at']; + // /** * @return \Illuminate\Database\Eloquent\Relations\HasMany @@ -25,13 +27,4 @@ class AccountType extends Model { return $this->hasMany('FireflyIII\Models\Account'); } - - /** - * @return array - */ - /** @noinspection PhpMissingParentCallCommonInspection */ - public function getDates() - { - return ['created_at', 'updated_at']; - } } diff --git a/app/Models/Bill.php b/app/Models/Bill.php index 4558cdb4e7..d8ca9ef6dd 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -28,8 +28,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property boolean $match_encrypted * @property-read Collection|TransactionJournal[] $transactionjournals * @property-read User $user - * @property Carbon $nextExpectedMatch - * @property Carbon $lastFoundMatch + * @property Carbon $nextExpectedMatch + * @property Carbon $lastFoundMatch */ class Bill extends Model { @@ -38,15 +38,7 @@ class Bill extends Model = ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',]; protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted']; - - - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at', 'date']; - } + protected $dates = ['created_at', 'updated_at', 'date']; /** * @param $value diff --git a/app/Models/Budget.php b/app/Models/Budget.php index a10bb8926d..ed72b0b1e8 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -23,8 +23,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property-read Collection|BudgetLimit[] $budgetlimits * @property-read Collection|TransactionJournal[] $transactionjournals * @property-read User $user - * @property string $dateFormatted - * @property string $budgeted + * @property string $dateFormatted + * @property string $budgeted */ class Budget extends Model { @@ -33,6 +33,7 @@ class Budget extends Model protected $fillable = ['user_id', 'name', 'active']; protected $hidden = ['encrypted']; + protected $dates = ['created_at', 'updated_at', 'deleted_at', 'startdate', 'enddate']; /** * @param array $fields @@ -71,14 +72,6 @@ class Budget extends Model return $this->hasMany('FireflyIII\Models\BudgetLimit'); } - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at', 'deleted_at', 'startdate', 'enddate']; - } - /** * @param $value * diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php index ba44ed72b0..da5c87501f 100644 --- a/app/Models/BudgetLimit.php +++ b/app/Models/BudgetLimit.php @@ -22,6 +22,7 @@ class BudgetLimit extends Model { protected $hidden = ['amount_encrypted']; + protected $date = ['created_at', 'updated_at', 'startdate']; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo @@ -31,14 +32,6 @@ class BudgetLimit extends Model return $this->belongsTo('FireflyIII\Models\Budget'); } - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at', 'startdate']; - } - /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ diff --git a/app/Models/Category.php b/app/Models/Category.php index 037b32af0c..84e79ae404 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -29,6 +29,7 @@ class Category extends Model protected $fillable = ['user_id', 'name']; protected $hidden = ['encrypted']; + protected $dates = ['created_at', 'updated_at', 'deleted_at']; /** * @param array $fields @@ -58,15 +59,6 @@ class Category extends Model } - /** - * @codeCoverageIgnore - * @return string[] - */ - public function getDates() - { - return ['created_at', 'updated_at', 'deleted_at']; - } - /** * @codeCoverageIgnore * diff --git a/app/Models/Component.php b/app/Models/Component.php index 82ffc02f1c..1a950ad808 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -5,27 +5,10 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; /** - * FireflyIII\Models\Component + * Class Component * - * @property integer $id - * @property Carbon $created_at - * @property Carbon $updated_at - * @property Carbon $deleted_at - * @property string $name - * @property integer $user_id - * @property string $class + * @package FireflyIII\Models */ class Component extends Model { - use SoftDeletes; - - protected $fillable = ['user_id', 'name', 'class']; - - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at', 'deleted_at']; - } } diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.php index e4c3d105eb..bcb778f773 100644 --- a/app/Models/LimitRepetition.php +++ b/app/Models/LimitRepetition.php @@ -21,6 +21,7 @@ class LimitRepetition extends Model { protected $hidden = ['amount_encrypted']; + protected $dates = ['created_at', 'updated_at', 'startdate', 'enddate']; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo @@ -30,14 +31,6 @@ class LimitRepetition extends Model return $this->belongsTo('FireflyIII\Models\BudgetLimit'); } - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at', 'startdate', 'enddate']; - } - /** * @param $value */ diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index efce246557..73c1ab74db 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -27,7 +27,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property-read Account $account * @property-read Collection|PiggyBankRepetition[] $piggyBankRepetitions * @property-read Collection|PiggyBankEvent[] $piggyBankEvents - * @property string $reminder + * @property string $reminder */ class PiggyBank extends Model { @@ -36,6 +36,7 @@ class PiggyBank extends Model protected $fillable = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate', 'remind_me', 'reminder_skip']; protected $hidden = ['targetamount_encrypted', 'encrypted']; + protected $dates = ['created_at', 'updated_at', 'deleted_at', 'startdate', 'targetdate']; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo @@ -72,14 +73,6 @@ class PiggyBank extends Model return $this->hasMany('FireflyIII\Models\PiggyBankRepetition'); } - /** - * @return string[] - */ - public function getDates() - { - return ['created_at', 'updated_at', 'deleted_at', 'startdate', 'targetdate']; - } - /** * * @param $value diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php index e373ab93a1..310b34ed09 100644 --- a/app/Models/PiggyBankEvent.php +++ b/app/Models/PiggyBankEvent.php @@ -21,15 +21,7 @@ class PiggyBankEvent extends Model protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount']; protected $hidden = ['amount_encrypted']; - - /** - * @return array - */ - /** @noinspection PhpMissingParentCallCommonInspection */ - public function getDates() - { - return ['created_at', 'updated_at', 'date']; - } + protected $dates = ['created_at', 'updated_at', 'date']; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index 25ada5c27b..92b0b7564b 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -24,14 +24,7 @@ class PiggyBankRepetition extends Model protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount']; protected $hidden = ['currentamount_encrypted']; - - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at', 'startdate', 'targetdate']; - } + protected $dates = ['created_at', 'updated_at', 'startdate', 'targetdate']; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo diff --git a/app/Models/Preference.php b/app/Models/Preference.php index d66b36476e..625548d171 100644 --- a/app/Models/Preference.php +++ b/app/Models/Preference.php @@ -23,7 +23,7 @@ class Preference extends Model protected $fillable = ['user_id', 'data', 'name']; protected $hidden = ['data_encrypted', 'name_encrypted']; - +protected $dates = ['created_at', 'updated_at']; /** * @param $value * @@ -39,14 +39,6 @@ class Preference extends Model return json_decode($data); } - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at']; - } - /** * @param $value */ diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 68868b0da4..2fb076cc1d 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -41,8 +41,9 @@ class Tag extends Model 'date' => 'date', 'latitude' => 'numeric|min:-90|max:90', 'longitude' => 'numeric|min:-90|max:90', - 'tagMode' => 'required|in:nothing,balancingAct,advancePayment' + 'tagMode' => 'required|in:nothing,balancingAct,advancePayment', ]; + protected $dates = ['created_at', 'updated_at', 'date']; /** * @param array $fields @@ -76,15 +77,6 @@ class Tag extends Model } - /** - * @codeCoverageIgnore - * @return string[] - */ - public function getDates() - { - return ['created_at', 'updated_at', 'date']; - } - /** * Save the model to the database. * diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 1bdd1148a1..2357277d52 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -33,8 +33,10 @@ class Transaction extends Model 'account_id' => 'required|exists:accounts,id', 'transaction_journal_id' => 'required|exists:transaction_journals,id', 'description' => 'between:1,255', - 'amount' => 'required|numeric' + 'amount' => 'required|numeric', ]; + protected $dates = ['created_at', 'updated_at', 'deleted_at']; + use SoftDeletes, ValidatingTrait; /** @@ -55,14 +57,6 @@ class Transaction extends Model return $value; } - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at', 'deleted_at']; - } - /** * @param EloquentBuilder $query * @param Carbon $date diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php index 6a223428b4..1ed3691164 100644 --- a/app/Models/TransactionCurrency.php +++ b/app/Models/TransactionCurrency.php @@ -25,14 +25,7 @@ class TransactionCurrency extends Model protected $fillable = ['name', 'code', 'symbol']; - - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at', 'deleted_at']; - } + protected $dates = ['created_at', 'updated_at', 'deleted_at']; /** * @return \Illuminate\Database\Eloquent\Relations\HasMany diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.php index 5d2830778d..51275cf773 100644 --- a/app/Models/TransactionGroup.php +++ b/app/Models/TransactionGroup.php @@ -22,13 +22,7 @@ class TransactionGroup extends Model { use SoftDeletes; - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at', 'deleted_at']; - } + protected $dates = ['created_at', 'updated_at', 'deleted_at']; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php index 6df752b214..e6778eb8cb 100644 --- a/app/Models/TransactionType.php +++ b/app/Models/TransactionType.php @@ -24,13 +24,7 @@ class TransactionType extends Model const TRANSFER = 'Transfer'; const OPENING_BALANCE = 'Opening balance'; - /** - * @return array - */ - public function getDates() - { - return ['created_at', 'updated_at', 'deleted_at']; - } + protected $dates = ['created_at', 'updated_at', 'deleted_at']; /** * @return bool