mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Combination of initial files and some new code for login and user registration.
This commit is contained in:
36
app/models/Account.php
Normal file
36
app/models/Account.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Account extends Eloquent
|
||||
{
|
||||
|
||||
public function accountType()
|
||||
{
|
||||
return $this->belongsTo('AccountType');
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasMany('Transaction');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('User');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an accounts current balance.
|
||||
*
|
||||
* @param \Carbon\Carbon $date
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function balance(\Carbon\Carbon $date = null)
|
||||
{
|
||||
$date = is_null($date) ? new \Carbon\Carbon : $date;
|
||||
return floatval($this->transactions()->sum('amount'));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user