mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Add / Update expense categories from API (#1124)
* Expense categories * add dependencies * expense categories * expense categories * expense categories
This commit is contained in:
parent
a4b919f188
commit
dedb85c8d6
@ -1,5 +1,6 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Models\Expense;
|
||||
use App\Ninja\Repositories\ExpenseRepository;
|
||||
use App\Services\ExpenseService;
|
||||
@ -75,8 +76,8 @@ class ExpenseApiController extends BaseAPIController
|
||||
$expense = $this->expenseRepo->save($request->input());
|
||||
|
||||
$expense = Expense::scope($expense->public_id)
|
||||
->with('client', 'invoice', 'vendor')
|
||||
->first();
|
||||
->with('client', 'invoice', 'vendor')
|
||||
->first();
|
||||
|
||||
return $this->itemResponse($expense);
|
||||
}
|
||||
@ -146,4 +147,6 @@ class ExpenseApiController extends BaseAPIController
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
39
app/Http/Controllers/ExpenseCategoryApiController.php
Normal file
39
app/Http/Controllers/ExpenseCategoryApiController.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use View;
|
||||
use Utils;
|
||||
use Input;
|
||||
use Session;
|
||||
use App\Services\ExpenseCategoryService;
|
||||
use App\Http\Requests\CreateExpenseCategoryRequest;
|
||||
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 update(UpdateExpenseCategoryRequest $request)
|
||||
{
|
||||
$category = $this->categoryRepo->save($request->input(), $request->entity());
|
||||
|
||||
return $this->itemResponse($category);
|
||||
}
|
||||
|
||||
public function store(CreateExpenseCategoryRequest $request)
|
||||
{
|
||||
$category = $this->categoryRepo->save($request->input());
|
||||
|
||||
return $this->itemResponse($category);
|
||||
|
||||
}
|
||||
}
|
@ -309,7 +309,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function()
|
||||
Route::get('dashboard', 'DashboardApiController@index');
|
||||
Route::resource('documents', 'DocumentAPIController');
|
||||
Route::resource('vendors', 'VendorApiController');
|
||||
Route::resource('expenses', 'ExpenseApiController');
|
||||
Route::post('createExpenseCategory', 'ExpenseCategoryApiController@store');
|
||||
Route::put('updateExpenseCategory/{expense_category_id}', 'ExpenseCategoryApiController@update');
|
||||
});
|
||||
|
||||
// Redirects for legacy links
|
||||
|
Loading…
Reference in New Issue
Block a user