mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-23 09:26:29 -06:00
Recreated the JSON controller to fix auto-complete forms.
This commit is contained in:
parent
4e166c7d2e
commit
ab508a3d9e
65
app/controllers/JsonController.php
Normal file
65
app/controllers/JsonController.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class JsonController
|
||||
*
|
||||
*/
|
||||
class JsonController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a list of categories.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function categories()
|
||||
{
|
||||
/** @var \FireflyIII\Database\Category $categories */
|
||||
$categories = App::make('FireflyIII\Database\Category');
|
||||
$list = $categories->get();
|
||||
$return = [];
|
||||
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()
|
||||
{
|
||||
/** @var \FireflyIII\Database\Account $accounts */
|
||||
$accounts = App::make('FireflyIII\Database\Account');
|
||||
$list = $accounts->getExpenseAccounts();
|
||||
$return = [];
|
||||
foreach ($list as $entry) {
|
||||
$return[] = $entry->name;
|
||||
}
|
||||
|
||||
return Response::json($return);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function revenueAccounts()
|
||||
{
|
||||
/** @var \FireflyIII\Database\Account $accounts */
|
||||
$accounts = App::make('FireflyIII\Database\Account');
|
||||
$list = $accounts->getRevenueAccounts();
|
||||
$return = [];
|
||||
foreach ($list as $entry) {
|
||||
$return[] = $entry->name;
|
||||
}
|
||||
|
||||
return Response::json($return);
|
||||
|
||||
}
|
||||
}
|
@ -174,6 +174,12 @@ Route::group(
|
||||
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
|
||||
Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']); # even though nothing is cached.
|
||||
|
||||
// JSON controller
|
||||
Route::get('/json/expense-accounts', ['uses' => 'JsonController@expenseAccounts', 'as' => 'json.expense-accounts']);
|
||||
Route::get('/json/revenue-accounts', ['uses' => 'JsonController@revenueAccounts', 'as' => 'json.revenue-accounts']);
|
||||
Route::get('/json/categories', ['uses' => 'JsonController@categories', 'as' => 'json.categories']);
|
||||
|
||||
|
||||
// piggy bank controller
|
||||
Route::get('/piggybanks', ['uses' => 'PiggybankController@index', 'as' => 'piggybanks.index']);
|
||||
Route::get('/piggybanks/add/{piggybank}', ['uses' => 'PiggybankController@add']); # add money
|
||||
|
Loading…
Reference in New Issue
Block a user