2014-11-12 13:52:34 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class JsonController
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class JsonController extends BaseController
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a list of categories.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
|
|
|
public function categories()
|
|
|
|
{
|
2014-12-13 15:54:52 -06:00
|
|
|
/** @var \FireflyIII\Database\Category\Category $categories */
|
|
|
|
$categories = App::make('FireflyIII\Database\Category\Category');
|
2014-11-12 15:36:02 -06:00
|
|
|
$list = $categories->get();
|
|
|
|
$return = [];
|
2014-11-12 13:52:34 -06:00
|
|
|
foreach ($list as $entry) {
|
|
|
|
$return[] = $entry->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Response::json($return);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a JSON list of all beneficiaries.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
|
|
|
public function expenseAccounts()
|
|
|
|
{
|
2014-12-13 15:54:52 -06:00
|
|
|
/** @var \FireflyIII\Database\Account\Account $accounts */
|
|
|
|
$accounts = App::make('FireflyIII\Database\Account\Account');
|
2015-01-17 00:25:44 -06:00
|
|
|
$list = $accounts->getAccountsByType(['Expense account', 'Beneficiary account']);
|
2014-11-12 15:36:02 -06:00
|
|
|
$return = [];
|
2014-11-12 13:52:34 -06:00
|
|
|
foreach ($list as $entry) {
|
|
|
|
$return[] = $entry->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Response::json($return);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
|
|
|
public function revenueAccounts()
|
|
|
|
{
|
2014-12-13 15:54:52 -06:00
|
|
|
/** @var \FireflyIII\Database\Account\Account $accounts */
|
|
|
|
$accounts = App::make('FireflyIII\Database\Account\Account');
|
2015-01-17 00:25:44 -06:00
|
|
|
$list = $accounts->getAccountsByType(['Revenue account']);
|
2014-11-12 15:36:02 -06:00
|
|
|
$return = [];
|
2014-11-12 13:52:34 -06:00
|
|
|
foreach ($list as $entry) {
|
|
|
|
$return[] = $entry->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Response::json($return);
|
|
|
|
|
|
|
|
}
|
2015-01-01 23:16:49 -06:00
|
|
|
}
|