akaunting 3.0 (the last dance)

This commit is contained in:
Burak Civan
2022-06-01 10:15:55 +03:00
parent cead09f6d4
commit d9c0764572
3812 changed files with 126831 additions and 102949 deletions

View File

@ -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());
}
}
}