1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 22:22:32 +01:00

expense categories

This commit is contained in:
David Bomba 2016-10-28 08:47:20 +11:00
parent 06533b2430
commit 9cf55301e8
3 changed files with 45 additions and 22 deletions

View File

@ -1,10 +1,7 @@
<?php namespace App\Http\Controllers;
use App\Http\Requests\CreateExpenseCategoryRequest;
use App\Http\Requests\Request;
use App\Http\Requests\UpdateExpenseCategoryRequest;
use App\Models\Expense;
use App\Ninja\Repositories\ExpenseCategoryRepository;
use App\Ninja\Repositories\ExpenseRepository;
use App\Services\ExpenseService;
use App\Http\Requests\ExpenseRequest;
@ -16,17 +13,15 @@ class ExpenseApiController extends BaseAPIController
// Expenses
protected $expenseRepo;
protected $expenseService;
protected $categoryRepo;
protected $entityType = ENTITY_EXPENSE;
public function __construct(ExpenseCategoryRepository $categoryRepo, ExpenseRepository $expenseRepo, ExpenseService $expenseService)
public function __construct(ExpenseRepository $expenseRepo, ExpenseService $expenseService)
{
parent::__construct();
$this->expenseRepo = $expenseRepo;
$this->expenseService = $expenseService;
$this->categoryRepo = $categoryRepo;
}
/**
@ -152,19 +147,6 @@ class ExpenseApiController extends BaseAPIController
}
public function updateCategory(UpdateExpenseCategoryRequest $request)
{
$category = $this->categoryRepo->save($request->input(), $request->entity());
return $this->itemResponse($category);
}
public function addCategory(CreateExpenseCategoryRequest $request)
{
$category = $this->categoryRepo->save($request->input());
return $this->itemResponse($category);
}
}

View File

@ -0,0 +1,41 @@
<?php namespace App\Http\Controllers;
use View;
use Utils;
use Input;
use Session;
use App\Services\ExpenseCategoryService;
use App\Ninja\Repositories\ExpenseCategoryRepository;
use App\Http\Requests\CreateExpenseCategoryRequest;
use App\Http\Requests\UpdateExpenseCategoryRequest;
use App\Http\Requests\UpdateExpenseCategoryRequest;
use App\Ninja\Repositories\ExpenseCategoryRepository;
class ExpenseCategoryApiController extends BaseAPIController
{
protected $categoryRepo;
protected $categoryService;
protected $entityType = ENTITY_EXPENSE_CATEGORY;
public function __construct(ExpenseCategoryRepository $categoryRepo, ExpenseCategoryService $categoryService)
{
$this->categoryRepo = $categoryRepo;
$this->categoryService = $categoryService;
}
public function updateCategory(UpdateExpenseCategoryRequest $request)
{
$category = $this->categoryRepo->save($request->input(), $request->entity());
return $this->itemResponse($category);
}
public function addCategory(CreateExpenseCategoryRequest $request)
{
$category = $this->categoryRepo->save($request->input());
return $this->itemResponse($category);
}
}

View File

@ -309,8 +309,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function()
Route::get('dashboard', 'DashboardApiController@index');
Route::resource('documents', 'DocumentAPIController');
Route::resource('vendors', 'VendorApiController');
Route::post('createExpenseCategory', 'ExpenseApiController@addCategory');
Route::put('updateExpenseCategory/{expense_category_id}', 'ExpenseApiController@updateCategory');
Route::post('createExpenseCategory', 'ExpenseCategoryApiController@store');
Route::put('updateExpenseCategory/{expense_category_id}', 'ExpenseCategoryApiController@update');
});
// Redirects for legacy links