2014-07-14 23:58:08 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
2014-07-15 00:08:13 -05:00
|
|
|
use Firefly\Storage\Budget\BudgetRepositoryInterface as Bud;
|
|
|
|
use Firefly\Storage\Category\CategoryRepositoryInterface as Cat;
|
2014-07-14 23:58:08 -05:00
|
|
|
use Firefly\Storage\Component\ComponentRepositoryInterface as CRI;
|
|
|
|
|
|
|
|
class JsonController extends BaseController
|
|
|
|
{
|
2014-07-15 00:08:13 -05:00
|
|
|
protected $accounts;
|
|
|
|
protected $components;
|
|
|
|
protected $categories;
|
|
|
|
protected $budgets;
|
2014-07-14 23:58:08 -05:00
|
|
|
|
2014-07-15 00:08:13 -05:00
|
|
|
public function __construct(ARI $accounts, CRI $components, Cat $categories, Bud $budgets)
|
2014-07-14 23:58:08 -05:00
|
|
|
{
|
|
|
|
$this->components = $components;
|
|
|
|
$this->accounts = $accounts;
|
2014-07-15 00:08:13 -05:00
|
|
|
$this->categories = $categories;
|
|
|
|
$this->budgets = $budgets;
|
2014-07-14 23:58:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a JSON list of all beneficiaries.
|
|
|
|
*/
|
|
|
|
public function beneficiaries()
|
|
|
|
{
|
|
|
|
$list = $this->accounts->getBeneficiaries();
|
|
|
|
$return = [];
|
|
|
|
foreach ($list as $entry) {
|
|
|
|
$return[] = $entry->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Response::json($return);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Responds some JSON for typeahead fields.
|
|
|
|
*/
|
|
|
|
public function categories()
|
|
|
|
{
|
2014-07-15 00:08:13 -05:00
|
|
|
$list = $this->categories->get();
|
|
|
|
$return = [];
|
|
|
|
foreach ($list as $entry) {
|
|
|
|
$return[] = $entry->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Response::json($return);
|
2014-07-14 23:58:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|