Move from getDates to array dates.

This commit is contained in:
James Cole 2016-01-15 22:32:21 +01:00
parent 0620830b10
commit f949d2476b
18 changed files with 31 additions and 170 deletions

View File

@ -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
*

View File

@ -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
*/

View File

@ -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'];
}
}

View File

@ -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

View File

@ -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
*

View File

@ -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
*/

View File

@ -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
*

View File

@ -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'];
}
}

View File

@ -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
*/

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
*/

View File

@ -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.
*

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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