References

This commit is contained in:
James Cole 2015-02-06 05:14:27 +01:00
parent ab52bdec15
commit 804a97cad7
17 changed files with 243 additions and 25 deletions

View File

@ -26,5 +26,4 @@ class Account extends Model
} }
} }

View File

@ -5,6 +5,15 @@ use Illuminate\Database\Eloquent\Model;
class Bill extends Model class Bill extends Model
{ {
// public function transactionjournals()
{
return $this->hasMany('TransactionJournal');
}
public function user()
{
return $this->belongsTo('User');
}
} }

View File

@ -5,6 +5,26 @@ use Illuminate\Database\Eloquent\Model;
class Budget extends Model class Budget extends Model
{ {
//
public function budgetlimits()
{
return $this->hasMany('BudgetLimit');
}
public function limitrepetitions()
{
return $this->hasManyThrough('LimitRepetition', 'BudgetLimit', 'budget_id');
}
public function transactionjournals()
{
return $this->belongsToMany('TransactionJournal', 'budget_transaction_journal', 'budget_id');
}
public function user()
{
return $this->belongsTo('User');
}
} }

View File

@ -5,6 +5,14 @@ use Illuminate\Database\Eloquent\Model;
class BudgetLimit extends Model class BudgetLimit extends Model
{ {
// public function budget()
{
return $this->belongsTo('Budget');
}
public function limitrepetitions()
{
return $this->hasMany('LimitRepetition');
}
} }

View File

@ -5,6 +5,14 @@ use Illuminate\Database\Eloquent\Model;
class Category extends Model class Category extends Model
{ {
// public function transactionjournals()
{
return $this->belongsToMany('TransactionJournal', 'category_transaction_journal', 'category_id');
}
public function user()
{
return $this->belongsTo('User');
}
} }

View File

@ -5,6 +5,9 @@ use Illuminate\Database\Eloquent\Model;
class LimitRepetition extends Model class LimitRepetition extends Model
{ {
// public function budgetLimit()
{
return $this->belongsTo('BudgetLimit');
}
} }

View File

@ -5,6 +5,23 @@ use Illuminate\Database\Eloquent\Model;
class PiggyBank extends Model class PiggyBank extends Model
{ {
// public function account()
{
return $this->belongsTo('Account');
}
public function piggyBankEvents()
{
return $this->hasMany('PiggyBankEvent');
}
public function piggyBankRepetitions()
{
return $this->hasMany('PiggyBankRepetition');
}
public function reminders()
{
return $this->morphMany('Reminder', 'remindersable');
}
} }

View File

@ -5,6 +5,14 @@ use Illuminate\Database\Eloquent\Model;
class PiggyBankEvent extends Model class PiggyBankEvent extends Model
{ {
// public function piggyBank()
{
return $this->belongsTo('PiggyBank');
}
public function transactionJournal()
{
return $this->belongsTo('TransactionJournal');
}
} }

View File

@ -5,6 +5,9 @@ use Illuminate\Database\Eloquent\Model;
class PiggyBankRepetition extends Model class PiggyBankRepetition extends Model
{ {
// public function piggyBank()
{
return $this->belongsTo('PiggyBank');
}
} }

View File

@ -5,6 +5,19 @@ use Illuminate\Database\Eloquent\Model;
class Preference extends Model class Preference extends Model
{ {
// public function getDataAttribute($value)
{
return json_decode($value);
}
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value);
}
public function user()
{
return $this->belongsTo('User');
}
} }

View File

@ -5,6 +5,15 @@ use Illuminate\Database\Eloquent\Model;
class Reminder extends Model class Reminder extends Model
{ {
// public function remindersable()
{
return $this->morphTo();
}
public function user()
{
return $this->belongsTo('User');
}
} }

View File

@ -5,6 +5,14 @@ use Illuminate\Database\Eloquent\Model;
class Transaction extends Model class Transaction extends Model
{ {
// public function account()
{
return $this->belongsTo('Account');
}
public function transactionJournal()
{
return $this->belongsTo('TransactionJournal');
}
} }

View File

@ -5,6 +5,9 @@ use Illuminate\Database\Eloquent\Model;
class TransactionCurrency extends Model class TransactionCurrency extends Model
{ {
// public function transactionJournals()
{
return $this->hasMany('TransactionJournal');
}
} }

View File

@ -5,6 +5,15 @@ use Illuminate\Database\Eloquent\Model;
class TransactionGroup extends Model class TransactionGroup extends Model
{ {
// public function transactionjournals()
{
return $this->belongsToMany('TransactionJournal');
}
public function user()
{
return $this->belongsTo('User');
}
} }

View File

@ -5,6 +5,67 @@ use Illuminate\Database\Eloquent\Model;
class TransactionJournal extends Model class TransactionJournal extends Model
{ {
// public function bill()
{
return $this->belongsTo('Bill');
}
public function budgets()
{
return $this->belongsToMany('Budget');
}
public function categories()
{
return $this->belongsToMany('Category');
}
public function getDescriptionAttribute($value)
{
if ($this->encrypted) {
return Crypt::decrypt($value);
}
// @codeCoverageIgnoreStart
return $value;
// @codeCoverageIgnoreEnd
}
public function piggyBankEvents()
{
return $this->hasMany('PiggyBankEvent');
}
public function setDescriptionAttribute($value)
{
$this->attributes['description'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
}
public function transactionCurrency()
{
return $this->belongsTo('TransactionCurrency');
}
public function transactionType()
{
return $this->belongsTo('TransactionType');
}
public function transactiongroups()
{
return $this->belongsToMany('TransactionGroup');
}
public function transactions()
{
return $this->hasMany('Transaction');
}
public function user()
{
return $this->belongsTo('User');
}
} }

View File

@ -5,6 +5,9 @@ use Illuminate\Database\Eloquent\Model;
class TransactionType extends Model class TransactionType extends Model
{ {
// public function transactionJournals()
{
return $this->hasMany('TransactionJournal');
}
} }

View File

@ -11,31 +11,68 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
use Authenticatable, CanResetPassword; use Authenticatable, CanResetPassword;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
* *
* @var array * @var array
*/ */
protected $fillable = ['name', 'email', 'password']; protected $fillable = ['name', 'email', 'password'];
/** /**
* The attributes excluded from the model's JSON form. * The attributes excluded from the model's JSON form.
* *
* @var array * @var array
*/ */
protected $hidden = ['password', 'remember_token']; protected $hidden = ['password', 'remember_token'];
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
public function accounts() public function accounts()
{ {
return $this->hasMany('Account'); return $this->hasMany('Account');
} }
public function bills()
{
return $this->hasMany('Bill');
}
public function budgets()
{
return $this->hasMany('Budget');
}
public function categories()
{
return $this->hasMany('Category');
}
public function piggyBanks()
{
return $this->hasManyThrough('PiggyBank', 'Account');
}
public function preferences()
{
return $this->hasMany('Preference');
}
public function reminders()
{
return $this->hasMany('Reminder');
}
public function transactionjournals()
{
return $this->hasMany('TransactionJournal');
}
public function setPasswordAttribute($value)
{
$this->attributes['password'] = Hash::make($value);
}
} }