New stuff! [skip ci]

This commit is contained in:
James Cole
2014-07-27 20:29:58 +02:00
parent b782bb8d93
commit 92f2e30ed1
22 changed files with 868 additions and 251 deletions

View File

@@ -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);
}
}