akaunting 3.0 (the last dance)
This commit is contained in:
@ -4,31 +4,31 @@ namespace App\Http\Controllers\Api\Banking;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use App\Http\Requests\Banking\Account as Request;
|
||||
use App\Http\Resources\Banking\Account as Resource;
|
||||
use App\Jobs\Banking\CreateAccount;
|
||||
use App\Jobs\Banking\DeleteAccount;
|
||||
use App\Jobs\Banking\UpdateAccount;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Transformers\Banking\Account as Transformer;
|
||||
|
||||
class Accounts extends ApiController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$accounts = Account::collect();
|
||||
|
||||
return $this->response->paginator($accounts, new Transformer());
|
||||
return Resource::collection($accounts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param $id
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
@ -39,20 +39,20 @@ class Accounts extends ApiController
|
||||
$account = Account::where('number', $id)->first();
|
||||
}
|
||||
|
||||
return $this->item($account, new Transformer());
|
||||
return new Resource($account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$account = $this->dispatch(new CreateAccount($request));
|
||||
|
||||
return $this->response->created(route('api.accounts.show', $account->id), $this->item($account, new Transformer()));
|
||||
return $this->created(route('api.accounts.show', $account->id), new Resource($account));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,16 +60,16 @@ class Accounts extends ApiController
|
||||
*
|
||||
* @param $account
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Account $account, Request $request)
|
||||
{
|
||||
try {
|
||||
$account = $this->dispatch(new UpdateAccount($account, $request));
|
||||
|
||||
return $this->item($account->fresh(), new Transformer());
|
||||
return new Resource($account->fresh());
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,29 +77,29 @@ class Accounts extends ApiController
|
||||
* Enable the specified resource in storage.
|
||||
*
|
||||
* @param Account $account
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function enable(Account $account)
|
||||
{
|
||||
$account = $this->dispatch(new UpdateAccount($account, request()->merge(['enabled' => 1])));
|
||||
|
||||
return $this->item($account->fresh(), new Transformer());
|
||||
return new Resource($account->fresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the specified resource in storage.
|
||||
*
|
||||
* @param Account $account
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function disable(Account $account)
|
||||
{
|
||||
try {
|
||||
$account = $this->dispatch(new UpdateAccount($account, request()->merge(['enabled' => 0])));
|
||||
|
||||
return $this->item($account->fresh(), new Transformer());
|
||||
return new Resource($account->fresh());
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,16 +107,16 @@ class Accounts extends ApiController
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Account $account
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Account $account)
|
||||
{
|
||||
try {
|
||||
$this->dispatch(new DeleteAccount($account));
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,48 +4,48 @@ namespace App\Http\Controllers\Api\Banking;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use App\Http\Requests\Banking\Reconciliation as Request;
|
||||
use App\Http\Resources\Banking\Reconciliation as Resource;
|
||||
use App\Jobs\Banking\CreateReconciliation;
|
||||
use App\Jobs\Banking\DeleteReconciliation;
|
||||
use App\Jobs\Banking\UpdateReconciliation;
|
||||
use App\Models\Banking\Reconciliation;
|
||||
use App\Transformers\Banking\Reconciliation as Transformer;
|
||||
|
||||
class Reconciliations extends ApiController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$items = Reconciliation::with('account')->collect();
|
||||
$reconciliations = Reconciliation::with('account')->collect();
|
||||
|
||||
return $this->response->paginator($items, new Transformer());
|
||||
return Resource::collection($reconciliations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param $reconciliation
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show(Reconciliation $reconciliation)
|
||||
{
|
||||
return $this->item($reconciliation, new Transformer());
|
||||
return new Resource($reconciliation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$reconciliation = $this->dispatch(new CreateReconciliation($request));
|
||||
|
||||
return $this->response->created(route('api.reconciliations.show', $reconciliation->id), $this->item($reconciliation, new Transformer()));
|
||||
return $this->created(route('api.reconciliations.show', $reconciliation->id), new Resource($reconciliation));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,29 +53,29 @@ class Reconciliations extends ApiController
|
||||
*
|
||||
* @param $reconciliation
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Reconciliation $reconciliation, Request $request)
|
||||
{
|
||||
$reconciliation = $this->dispatch(new UpdateReconciliation($reconciliation, $request));
|
||||
|
||||
return $this->item($reconciliation->fresh(), new Transformer());
|
||||
return new Resource($reconciliation->fresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Reconciliation $reconciliation
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Reconciliation $reconciliation)
|
||||
{
|
||||
try {
|
||||
$this->dispatch(new DeleteReconciliation($reconciliation));
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,48 +4,48 @@ namespace App\Http\Controllers\Api\Banking;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use App\Http\Requests\Banking\Transaction as Request;
|
||||
use App\Http\Resources\Banking\Transaction as Resource;
|
||||
use App\Jobs\Banking\CreateTransaction;
|
||||
use App\Jobs\Banking\DeleteTransaction;
|
||||
use App\Jobs\Banking\UpdateTransaction;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Transformers\Banking\Transaction as Transformer;
|
||||
|
||||
class Transactions extends ApiController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$transactions = Transaction::with('account', 'category', 'contact')->collect(['paid_at'=> 'desc']);
|
||||
|
||||
return $this->response->paginator($transactions, new Transformer());
|
||||
return Resource::collection($transactions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param Transaction $transaction
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show(Transaction $transaction)
|
||||
{
|
||||
return $this->item($transaction, new Transformer());
|
||||
return new Resource($transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$transaction = $this->dispatch(new CreateTransaction($request));
|
||||
|
||||
return $this->response->created(route('api.transactions.show', $transaction->id), $this->item($transaction, new Transformer()));
|
||||
return $this->created(route('api.transactions.show', $transaction->id), new Resource($transaction));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,29 +53,29 @@ class Transactions extends ApiController
|
||||
*
|
||||
* @param $transaction
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Transaction $transaction, Request $request)
|
||||
{
|
||||
$transaction = $this->dispatch(new UpdateTransaction($transaction, $request));
|
||||
|
||||
return $this->item($transaction->fresh(), new Transformer());
|
||||
return new Resource($transaction->fresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Transaction $transaction
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Transaction $transaction)
|
||||
{
|
||||
try {
|
||||
$this->dispatch(new DeleteTransaction($transaction));
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,18 +4,18 @@ namespace App\Http\Controllers\Api\Banking;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use App\Http\Requests\Banking\Transfer as Request;
|
||||
use App\Http\Resources\Banking\Transfer as Resource;
|
||||
use App\Jobs\Banking\CreateTransfer;
|
||||
use App\Jobs\Banking\UpdateTransfer;
|
||||
use App\Jobs\Banking\DeleteTransfer;
|
||||
use App\Models\Banking\Transfer;
|
||||
use App\Transformers\Banking\Transfer as Transformer;
|
||||
|
||||
class Transfers extends ApiController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -51,31 +51,31 @@ class Transfers extends ApiController
|
||||
$transfers->setCollection(collect($items));
|
||||
}
|
||||
|
||||
return $this->response->paginator($transfers, new Transformer());
|
||||
return Resource::collection($transfers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param Transfer $transfer
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show(Transfer $transfer)
|
||||
{
|
||||
return $this->item($transfer, new Transformer());
|
||||
return new Resource($transfer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$transfer = $this->dispatch(new CreateTransfer($request));
|
||||
|
||||
return $this->response->created(route('api.transfers.show', $transfer->id), $this->item($transfer, new Transformer()));
|
||||
return $this->created(route('api.transfers.show', $transfer->id), new Resource($transfer));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,29 +83,29 @@ class Transfers extends ApiController
|
||||
*
|
||||
* @param $transfer
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Transfer $transfer, Request $request)
|
||||
{
|
||||
$transfer = $this->dispatch(new UpdateTransfer($transfer, $request));
|
||||
|
||||
return $this->item($transfer->fresh(), new Transformer());
|
||||
return new Resource($transfer->fresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Transfer $transfer
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Transfer $transfer)
|
||||
{
|
||||
try {
|
||||
$this->dispatch(new DeleteTransfer($transfer));
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user