mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-23 23:13:18 -06:00
Clean up lots of models.
This commit is contained in:
parent
9f2729d0ff
commit
5b5acba816
@ -36,12 +36,25 @@ class Account extends Model
|
||||
{
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'active' => 'boolean',
|
||||
'encrypted' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
/** @var array */
|
||||
protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
|
||||
/** @var array */
|
||||
protected $hidden = ['virtual_balance_encrypted', 'encrypted'];
|
||||
protected $hidden = ['encrypted'];
|
||||
protected $rules
|
||||
= [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
@ -184,7 +197,7 @@ class Account extends Model
|
||||
public function getNameAttribute($value): string
|
||||
{
|
||||
|
||||
if (intval($this->encrypted) == 1) {
|
||||
if ($this->encrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,18 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
class AccountMeta extends Model
|
||||
{
|
||||
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
protected $fillable = ['account_id', 'name', 'data'];
|
||||
protected $table = 'account_meta';
|
||||
|
||||
|
@ -33,6 +33,18 @@ class AccountType extends Model
|
||||
const IMPORT = 'Import account';
|
||||
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
];
|
||||
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
|
||||
//
|
||||
|
@ -29,6 +29,21 @@ class Attachment extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'uploaded' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
/** @var array */
|
||||
protected $fillable = ['attachable_id', 'attachable_type', 'user_id', 'md5', 'filename', 'mime', 'title', 'notes', 'description', 'size', 'uploaded'];
|
||||
|
||||
/**
|
||||
|
@ -27,10 +27,24 @@ class AvailableBudget extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at', 'start_date', 'end_date'];
|
||||
/** @var array */
|
||||
protected $fillable = ['user_id', 'transaction_currency_id', 'amount', 'start_date', 'end_date'];
|
||||
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
|
@ -29,8 +29,26 @@ class Bill extends Model
|
||||
{
|
||||
|
||||
use ValidatingTrait;
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'date'];
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'date' => 'date',
|
||||
'skip' => 'int',
|
||||
'automatch' => 'boolean',
|
||||
'active' => 'boolean',
|
||||
'name_encrypted' => 'boolean',
|
||||
'match_encrypted' => 'boolean',
|
||||
];
|
||||
protected $fillable
|
||||
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
|
||||
'automatch', 'active',];
|
||||
|
@ -30,7 +30,23 @@ class Budget extends Model
|
||||
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at', 'startdate', 'enddate'];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'active' => 'boolean',
|
||||
'encrypted' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = ['user_id', 'name', 'active'];
|
||||
protected $hidden = ['encrypted'];
|
||||
protected $rules = ['name' => 'required|between:1,200',];
|
||||
@ -95,7 +111,7 @@ class Budget extends Model
|
||||
public function getNameAttribute($value)
|
||||
{
|
||||
|
||||
if (intval($this->encrypted) == 1) {
|
||||
if ($this->encrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
}
|
||||
|
||||
@ -115,8 +131,8 @@ class Budget extends Model
|
||||
*/
|
||||
public function setNameAttribute($value)
|
||||
{
|
||||
$this->attributes['name'] = Crypt::encrypt($value);
|
||||
$this->attributes['encrypted'] = true;
|
||||
$this->attributes['name'] = $value;
|
||||
$this->attributes['encrypted'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,20 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class BudgetLimit extends Model
|
||||
{
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'startdate'];
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'startdate' => 'date',
|
||||
'repeats' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
protected $hidden = ['amount_encrypted'];
|
||||
|
||||
/**
|
||||
|
@ -29,10 +29,26 @@ class Category extends Model
|
||||
{
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'encrypted' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $fillable = ['user_id', 'name'];
|
||||
/** @var array */
|
||||
protected $hidden = ['encrypted'];
|
||||
/** @var array */
|
||||
protected $rules = ['name' => 'required|between:1,200',];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
@ -86,7 +102,7 @@ class Category extends Model
|
||||
public function getNameAttribute($value)
|
||||
{
|
||||
|
||||
if (intval($this->encrypted) == 1) {
|
||||
if ($this->encrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
}
|
||||
|
||||
@ -99,8 +115,8 @@ class Category extends Model
|
||||
*/
|
||||
public function setNameAttribute($value)
|
||||
{
|
||||
$this->attributes['name'] = Crypt::encrypt($value);
|
||||
$this->attributes['encrypted'] = true;
|
||||
$this->attributes['name'] = $value;
|
||||
$this->attributes['encrypted'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,17 @@ class Configuration extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $table = 'configuration';
|
||||
|
||||
|
@ -23,6 +23,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class ExportJob extends Model
|
||||
{
|
||||
/** @var array */
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
|
@ -27,6 +27,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
class ImportJob extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
|
||||
protected $validStatus
|
||||
= [
|
||||
'import_status_never_started', // initial state
|
||||
|
@ -26,6 +26,18 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
class LimitRepetition extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'startdate' => 'date',
|
||||
'enddate' => 'date',
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'startdate', 'enddate'];
|
||||
protected $hidden = ['amount_encrypted'];
|
||||
|
||||
@ -38,10 +50,10 @@ class LimitRepetition extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$object = self::where('limit_repetitions.id', $value)
|
||||
->leftJoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
|
||||
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
|
||||
->where('budgets.user_id', auth()->user()->id)
|
||||
->first(['limit_repetitions.*']);
|
||||
->leftJoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
|
||||
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
|
||||
->where('budgets.user_id', auth()->user()->id)
|
||||
->first(['limit_repetitions.*']);
|
||||
if ($object) {
|
||||
return $object;
|
||||
}
|
||||
|
@ -23,10 +23,20 @@ use League\CommonMark\CommonMarkConverter;
|
||||
*/
|
||||
class Note extends Model
|
||||
{
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $fillable = ['title', 'text'];
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -29,10 +29,25 @@ class PiggyBank extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at', 'startdate', 'targetdate'];
|
||||
protected $fillable
|
||||
= ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate'];
|
||||
protected $hidden = ['targetamount_encrypted', 'encrypted'];
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'startdate' => 'date',
|
||||
'targetdate' => 'date',
|
||||
'order' => 'int',
|
||||
'active' => 'boolean',
|
||||
'encrypted' => 'boolean',
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at', 'startdate', 'targetdate'];
|
||||
protected $fillable = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate'];
|
||||
protected $hidden = ['targetamount_encrypted', 'encrypted'];
|
||||
|
||||
/**
|
||||
* @param PiggyBank $value
|
||||
@ -86,7 +101,7 @@ class PiggyBank extends Model
|
||||
public function getNameAttribute($value)
|
||||
{
|
||||
|
||||
if (intval($this->encrypted) == 1) {
|
||||
if ($this->encrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
}
|
||||
|
||||
@ -144,8 +159,8 @@ class PiggyBank extends Model
|
||||
*/
|
||||
public function setNameAttribute($value)
|
||||
{
|
||||
$this->attributes['name'] = Crypt::encrypt($value);
|
||||
$this->attributes['encrypted'] = true;
|
||||
$this->attributes['name'] = $value;
|
||||
$this->attributes['encrypted'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,17 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class PiggyBankEvent extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'date' => 'date',
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'date'];
|
||||
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
|
||||
protected $hidden = ['amount_encrypted'];
|
||||
|
@ -25,9 +25,21 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class PiggyBankRepetition extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'startdate' => 'date',
|
||||
'targetdate' => 'date',
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'startdate', 'targetdate'];
|
||||
protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];
|
||||
protected $hidden = ['currentamount_encrypted'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@ -27,6 +27,16 @@ use Log;
|
||||
class Preference extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
protected $fillable = ['user_id', 'data', 'name', 'data'];
|
||||
|
||||
|
@ -23,6 +23,17 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
*/
|
||||
class Role extends Model
|
||||
{
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
|
@ -26,6 +26,23 @@ class Rule extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'active' => 'boolean',
|
||||
'order' => 'int',
|
||||
'stop_processing' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* @param Rule $value
|
||||
*
|
||||
|
@ -22,6 +22,22 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*/
|
||||
class RuleAction extends Model
|
||||
{
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'active' => 'boolean',
|
||||
'order' => 'int',
|
||||
'stop_processing' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
|
@ -25,6 +25,22 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
class RuleGroup extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'active' => 'boolean',
|
||||
'order' => 'int',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
|
||||
protected $fillable = ['user_id', 'order', 'title', 'description', 'active'];
|
||||
|
||||
|
@ -22,6 +22,22 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*/
|
||||
class RuleTrigger extends Model
|
||||
{
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'active' => 'boolean',
|
||||
'order' => 'int',
|
||||
'stop_processing' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
|
@ -15,6 +15,7 @@ namespace FireflyIII\Models;
|
||||
|
||||
use Crypt;
|
||||
use FireflyIII\Support\Models\TagSupport;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
@ -25,11 +26,25 @@ use Watson\Validating\ValidatingTrait;
|
||||
*/
|
||||
class Tag extends TagSupport
|
||||
{
|
||||
protected $dates = ['created_at', 'updated_at', 'date'];
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'date' => 'date',
|
||||
'zoomLevel' => 'int',
|
||||
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'date', 'deleted_at'];
|
||||
protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode'];
|
||||
protected $rules = ['tag' => 'required|between:1,200',];
|
||||
|
||||
use ValidatingTrait;
|
||||
use ValidatingTrait, SoftDeletes;
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
|
@ -27,6 +27,18 @@ use Watson\Validating\ValidatingTrait;
|
||||
class Transaction extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'identifier' => 'int',
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $fillable = ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier'];
|
||||
protected $hidden = ['encrypted'];
|
||||
@ -37,7 +49,6 @@ class Transaction extends Model
|
||||
'description' => 'between:0,1024',
|
||||
'amount' => 'required|numeric',
|
||||
];
|
||||
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
/**
|
||||
|
@ -27,11 +27,20 @@ class TransactionCurrency extends Model
|
||||
{
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at','date'];
|
||||
protected $fillable = ['name', 'code', 'symbol'];
|
||||
protected $rules = ['name' => 'required|between:1,200', 'code' => 'required|between:3,3', 'symbol' => 'required|between:1,12'];
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
];
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* TransactionGroup.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class TransactionGroup
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
*/
|
||||
class TransactionGroup extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function transactionJournals()
|
||||
{
|
||||
return $this->belongsToMany('FireflyIII\Models\TransactionJournal');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('FireflyIII\User');
|
||||
}
|
||||
|
||||
}
|
@ -34,6 +34,25 @@ class TransactionJournal extends TransactionJournalSupport
|
||||
{
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
'date' => 'date',
|
||||
'interest_date' => 'date',
|
||||
'book_date' => 'date',
|
||||
'process_date' => 'date',
|
||||
'order' => 'int',
|
||||
'tag_count' => 'int',
|
||||
'encrypted' => 'boolean',
|
||||
'completed' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['created_at', 'updated_at', 'date', 'deleted_at', 'interest_date', 'book_date', 'process_date'];
|
||||
/** @var array */
|
||||
@ -65,9 +84,9 @@ class TransactionJournal extends TransactionJournalSupport
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$object = self::where('transaction_journals.id', $value)
|
||||
->with('transactionType')
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->where('user_id', auth()->user()->id)->first(['transaction_journals.*']);
|
||||
->with('transactionType')
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->where('user_id', auth()->user()->id)->first(['transaction_journals.*']);
|
||||
if (!is_null($object)) {
|
||||
return $object;
|
||||
}
|
||||
@ -352,8 +371,8 @@ class TransactionJournal extends TransactionJournalSupport
|
||||
*/
|
||||
public function setDescriptionAttribute($value)
|
||||
{
|
||||
$this->attributes['description'] = Crypt::encrypt($value);
|
||||
$this->attributes['encrypted'] = true;
|
||||
$this->attributes['description'] = $value;
|
||||
$this->attributes['encrypted'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,18 @@ class TransactionJournalMeta extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash'];
|
||||
protected $table = 'journal_meta';
|
||||
|
||||
|
@ -31,6 +31,18 @@ class TransactionType extends Model
|
||||
const TRANSFER = 'Transfer';
|
||||
const OPENING_BALANCE = 'Opening balance';
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'date',
|
||||
'updated_at' => 'date',
|
||||
'deleted_at' => 'date',
|
||||
];
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
|
@ -343,7 +343,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$account->save();
|
||||
|
||||
$this->updateMetadata($account, $data);
|
||||
$this->updateInitialBalance($account, $data);
|
||||
if ($this->validOpeningBalanceData($data)) {
|
||||
$this->updateInitialBalance($account, $data);
|
||||
}
|
||||
|
||||
return $account;
|
||||
}
|
||||
@ -448,7 +450,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
'description' => 'Initial balance for "' . $account->name . '"',
|
||||
'completed' => true,
|
||||
'date' => $data['openingBalanceDate'],
|
||||
'encrypted' => true,
|
||||
]
|
||||
);
|
||||
Log::debug(sprintf('Created new opening balance journal: #%d', $journal->id));
|
||||
|
Loading…
Reference in New Issue
Block a user