mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 22:58:09 +00:00
New stuff! [skip ci]
This commit is contained in:
@@ -12,6 +12,40 @@ use Carbon\Carbon;
|
||||
class EloquentBudgetRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $budgetId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function find($budgetId)
|
||||
{
|
||||
|
||||
return \Auth::user()->budgets()->find($budgetId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$set = \Auth::user()->budgets()->with(
|
||||
['limits' => function ($q) {
|
||||
$q->orderBy('limits.startdate', 'ASC');
|
||||
}, 'limits.limitrepetitions' => function ($q) {
|
||||
$q->orderBy('limit_repetitions.startdate', 'ASC');
|
||||
}]
|
||||
)->orderBy('name', 'ASC')->get();
|
||||
foreach ($set as $budget) {
|
||||
foreach ($budget->limits as $limit) {
|
||||
foreach ($limit->limitrepetitions as $rep) {
|
||||
$rep->left = $rep->left();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|mixed
|
||||
*/
|
||||
@@ -24,6 +58,7 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
||||
foreach ($list as $entry) {
|
||||
$return[intval($entry->id)] = $entry->name;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -69,6 +104,7 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
||||
$budget->count += count($limit->limitrepetitions);
|
||||
}
|
||||
}
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
@@ -123,30 +159,4 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
||||
return $budget;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return \Auth::user()->budgets()->with(
|
||||
['limits' => function ($q) {
|
||||
$q->orderBy('limits.startdate', 'ASC');
|
||||
}, 'limits.limitrepetitions' => function ($q) {
|
||||
$q->orderBy('limit_repetitions.startdate', 'ASC');
|
||||
}]
|
||||
)->orderBy('name', 'ASC')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $budgetId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function find($budgetId)
|
||||
{
|
||||
|
||||
return \Auth::user()->budgets()->find($budgetId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
||||
*/
|
||||
public function getTJByBudgetAndDateRange(\Budget $budget, Carbon $start, Carbon $end)
|
||||
{
|
||||
$result = $budget->transactionjournals()->after($start)->before($end)->get();
|
||||
$result = $budget->transactionjournals()->with('transactions')->after($start)->before($end)->get();
|
||||
|
||||
return $result;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user