mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Some preliminary work on issue #6. Breaks a lot of tests. [skip ci]
This commit is contained in:
@@ -34,6 +34,21 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
||||
)->where('piggybanks.id', $piggyBankId)->first(['piggybanks.*']);
|
||||
}
|
||||
|
||||
public function countRepeating()
|
||||
{
|
||||
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
||||
'accounts.user_id', \Auth::user()->id
|
||||
)->where('repeats', 1)->count();
|
||||
}
|
||||
|
||||
public function countNonrepeating()
|
||||
{
|
||||
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
||||
'accounts.user_id', \Auth::user()->id
|
||||
)->where('repeats', 0)->count();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -57,14 +72,8 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
||||
$account = isset($data['account_id']) ? $accounts->find($data['account_id']) : null;
|
||||
|
||||
|
||||
$piggyBank = new \Piggybank;
|
||||
$piggyBank = new \Piggybank($data);
|
||||
$piggyBank->account()->associate($account);
|
||||
$piggyBank->targetdate
|
||||
= isset($data['targetdate']) && strlen($data['targetdate']) > 0 ? $data['targetdate'] : null;
|
||||
$piggyBank->name = isset($data['name']) ? $data['name'] : null;
|
||||
$piggyBank->amount = 0;
|
||||
$piggyBank->target = floatval($data['target']);
|
||||
$piggyBank->order = 1;
|
||||
if ($piggyBank->validate()) {
|
||||
$piggyBank->save();
|
||||
}
|
||||
|
@@ -23,6 +23,16 @@ interface PiggybankRepositoryInterface
|
||||
*/
|
||||
public function count();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function countRepeating();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function countNonrepeating();
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
|
Reference in New Issue
Block a user