mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Moved some JSON around. [skip-ci]
This commit is contained in:
@@ -1,15 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||||
|
use Firefly\Storage\Budget\BudgetRepositoryInterface as Bud;
|
||||||
|
use Firefly\Storage\Category\CategoryRepositoryInterface as Cat;
|
||||||
use Firefly\Storage\Component\ComponentRepositoryInterface as CRI;
|
use Firefly\Storage\Component\ComponentRepositoryInterface as CRI;
|
||||||
|
|
||||||
class JsonController extends BaseController
|
class JsonController extends BaseController
|
||||||
{
|
{
|
||||||
|
protected $accounts;
|
||||||
|
protected $components;
|
||||||
|
protected $categories;
|
||||||
|
protected $budgets;
|
||||||
|
|
||||||
public function __construct(ARI $accounts,CRI $components)
|
public function __construct(ARI $accounts, CRI $components, Cat $categories, Bud $budgets)
|
||||||
{
|
{
|
||||||
$this->components = $components;
|
$this->components = $components;
|
||||||
$this->accounts = $accounts;
|
$this->accounts = $accounts;
|
||||||
|
$this->categories = $categories;
|
||||||
|
$this->budgets = $budgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +40,13 @@ class JsonController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function categories()
|
public function categories()
|
||||||
{
|
{
|
||||||
$list = $this->components->get();
|
$list = $this->categories->get();
|
||||||
|
$return = [];
|
||||||
|
foreach ($list as $entry) {
|
||||||
|
$return[] = $entry->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response::json($return);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Firefly\Storage\Budget;
|
||||||
|
|
||||||
|
|
||||||
|
interface BudgetRepositoryInterface {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Firefly\Storage\Budget;
|
||||||
|
|
||||||
|
|
||||||
|
class EloquentBudgetRepository implements BudgetRepositoryInterface {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Firefly\Storage\Category;
|
||||||
|
|
||||||
|
|
||||||
|
interface CategoryRepositoryInterface {
|
||||||
|
|
||||||
|
public function get();
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Firefly\Storage\Category;
|
||||||
|
|
||||||
|
|
||||||
|
class EloquentCategoryRepository implements CategoryRepositoryInterface {
|
||||||
|
public function get() {
|
||||||
|
return \Auth::user()->categories()->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -34,6 +34,15 @@ class StorageServiceProvider extends ServiceProvider
|
|||||||
'Firefly\Storage\Component\ComponentRepositoryInterface',
|
'Firefly\Storage\Component\ComponentRepositoryInterface',
|
||||||
'Firefly\Storage\Component\EloquentComponentRepository'
|
'Firefly\Storage\Component\EloquentComponentRepository'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->app->bind(
|
||||||
|
'Firefly\Storage\Budget\BudgetRepositoryInterface',
|
||||||
|
'Firefly\Storage\Budget\EloquentBudgetRepository'
|
||||||
|
);
|
||||||
|
$this->app->bind(
|
||||||
|
'Firefly\Storage\Category\CategoryRepositoryInterface',
|
||||||
|
'Firefly\Storage\Category\EloquentCategoryRepository'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -49,4 +49,19 @@ class User extends Elegant implements UserInterface, RemindableInterface
|
|||||||
return $this->hasMany('Preference');
|
return $this->hasMany('Preference');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function components()
|
||||||
|
{
|
||||||
|
return $this->hasMany('Component');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function budgets()
|
||||||
|
{
|
||||||
|
return $this->hasMany('Budget');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function categories()
|
||||||
|
{
|
||||||
|
return $this->hasMany('Category');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -1,3 +1,7 @@
|
|||||||
$.getJSON('accounts/beneficiaries').success(function (data) {
|
$.getJSON('json/beneficiaries').success(function (data) {
|
||||||
$('input[name="beneficiary"]').typeahead({ source: data });
|
$('input[name="beneficiary"]').typeahead({ source: data });
|
||||||
|
});
|
||||||
|
|
||||||
|
$.getJSON('json/categories').success(function (data) {
|
||||||
|
$('input[name="category"]').typeahead({ source: data });
|
||||||
});
|
});
|
Reference in New Issue
Block a user