mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-19 19:01:39 +00:00
New chart and lots of stuff for piggy banks
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
namespace FireflyIII\Database;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Firefly\Exception\FireflyException;
|
||||
use FireflyIII\Database\Ifaces\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\Ifaces\CUD;
|
||||
use FireflyIII\Database\Ifaces\PiggybankInterface;
|
||||
@@ -196,8 +197,10 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
// TODO: Implement find() method.
|
||||
throw new NotImplementedException;
|
||||
return \Piggybank::
|
||||
leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')
|
||||
->where('piggybanks.id','=',$id)
|
||||
->where('accounts.user_id', $this->getUser()->id)->first(['piggybanks.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,6 +237,18 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
public function findRepetitionByDate(\Piggybank $piggybank, Carbon $date)
|
||||
{
|
||||
$reps = $piggybank->piggybankrepetitions()->get();
|
||||
if ($reps->count() == 1) {
|
||||
return $reps->first();
|
||||
}
|
||||
if ($reps->count() == 0) {
|
||||
throw new FireflyException('Should always find a piggy bank repetition.');
|
||||
}
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Account $account
|
||||
*
|
||||
|
Reference in New Issue
Block a user