Add some hasManyThrough references

This commit is contained in:
James Cole 2014-11-21 11:11:52 +01:00
parent 243d942a6e
commit ec776bb6eb
6 changed files with 33 additions and 14 deletions

View File

@ -145,6 +145,7 @@ class Account extends Ardent
/**
* TODO see if this scope is still used.
*
* @param Builder $query
* @param array $types
*/
@ -157,6 +158,11 @@ class Account extends Ardent
$query->whereIn('account_types.type', $types);
}
public function transactionjournals()
{
return $this->hasManyThrough('TransactionJournal', 'Transaction');
}
/**
* User
*

View File

@ -3,16 +3,16 @@
/**
* Budget
*
* @property integer $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $name
* @property integer $user_id
* @property string $class
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
* @property integer $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $name
* @property integer $user_id
* @property string $class
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
* @property-read \User $user
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
* @property-read \User $user
* @method static \Illuminate\Database\Query\Builder|\Budget whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Budget whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Budget whereUpdatedAt($value)
@ -24,6 +24,11 @@ class Budget extends Component
{
protected $isSubclass = true;
public function limitrepetitions()
{
return $this->hasManyThrough('LimitRepetition', 'Limit');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/

View File

@ -58,7 +58,6 @@ class Component extends SingleTableInheritanceEntity
return $this->belongsToMany('TransactionJournal', 'component_transaction_journal', 'component_id');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/

View File

@ -80,6 +80,7 @@ class LimitRepetition extends Ardent
return $this->belongsTo('Limit');
}
/**
* TODO remove this method in favour of something in the FireflyIII libraries.
*

View File

@ -21,7 +21,7 @@ class TransactionCurrency extends Eloquent
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function transactionjournals()
public function transactionJournals()
{
return $this->hasMany('TransactionJournal');
}

View File

@ -40,9 +40,13 @@ class User extends Ardent implements UserInterface, RemindableInterface
public static $rules
= ['email' => 'required|email|unique:users,email', 'migrated' => 'required|boolean', 'password' => 'required|between:60,60',
'reset' => 'between:32,32',];
protected $fillable = ['email'];
= [
'email' => 'required|email|unique:users,email',
'migrated' => 'required|boolean',
'password' => 'required|between:60,60',
'reset' => 'between:32,32',
];
protected $fillable = ['email'];
/**
* The attributes excluded from the model's JSON form.
*
@ -92,6 +96,10 @@ class User extends Ardent implements UserInterface, RemindableInterface
{
return $this->hasManyThrough('Piggybank', 'Account');
}
public function transactions()
{
return $this->hasManyThrough('TransactionJournal', 'Transaction');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany