firefly-iii/app/models/User.php
2014-12-06 12:12:55 +01:00

118 lines
2.6 KiB
PHP

<?php
use Illuminate\Auth\Reminders\RemindableInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\UserTrait;
use Watson\Validating\ValidatingTrait;
class User extends Eloquent implements UserInterface, RemindableInterface
{
use UserTrait, RemindableTrait, ValidatingTrait;
public static $rules
= [
'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.
*
* @var array
*/
protected $hidden = ['remember_token'];
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function accounts()
{
return $this->hasMany('Account');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function budgets()
{
return $this->hasMany('Budget');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function categories()
{
return $this->hasMany('Category');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function components()
{
return $this->hasMany('Component');
}
public function piggybanks()
{
return $this->hasManyThrough('Piggybank', 'Account');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function preferences()
{
return $this->hasMany('Preference');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function recurringtransactions()
{
return $this->hasMany('RecurringTransaction');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function reminders()
{
return $this->hasMany('Reminder');
}
/**
* @param $value
*/
public function setPasswordAttribute($value)
{
$this->attributes['password'] = Hash::make($value);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function transactionjournals()
{
return $this->hasMany('TransactionJournal');
}
public function transactions()
{
return $this->hasManyThrough('TransactionJournal', 'Transaction');
}
}