.github
app
Abstracts
Builders
BulkActions
Classifiers
Console
Events
Exceptions
Exports
Http
Controllers
Api
Auth
Banking
Accounts.php
Reconciliations.php
Transactions.php
Transfers.php
Common
Document
Settings
Auth
Banking
Common
Install
Modals
Modules
Portal
Purchases
Sales
Settings
Wizard
Livewire
Middleware
Requests
Resources
Responses
ViewComposers
Kernel.php
Imports
Interfaces
Jobs
Listeners
Models
Notifications
Observers
Providers
Relations
Reports
Scopes
Traits
Utilities
View
Widgets
bootstrap
config
database
modules
overrides
public
resources
routes
storage
tests
.editorconfig
.env.example
.env.testing
.gitattributes
.gitignore
.htaccess
LICENSE.txt
README.md
SECURITY.md
artisan
composer.json
composer.lock
index.php
manifest.json
nginx.example.com.conf
package-lock.json
package.json
phpunit.xml
presets.js
safelist.txt
serviceworker.js
tailwind.config.js
web.config
webpack.mix.js
82 lines
2.1 KiB
PHP
82 lines
2.1 KiB
PHP
<?php
|
|
|
|
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;
|
|
|
|
class Transactions extends ApiController
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
public function index()
|
|
{
|
|
$transactions = Transaction::with('account', 'category', 'contact')->collect(['paid_at'=> 'desc']);
|
|
|
|
return Resource::collection($transactions);
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param Transaction $transaction
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
public function show(Transaction $transaction)
|
|
{
|
|
return new Resource($transaction);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param $request
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
$transaction = $this->dispatch(new CreateTransaction($request));
|
|
|
|
return $this->created(route('api.transactions.show', $transaction->id), new Resource($transaction));
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param $transaction
|
|
* @param $request
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
public function update(Transaction $transaction, Request $request)
|
|
{
|
|
$transaction = $this->dispatch(new UpdateTransaction($transaction, $request));
|
|
|
|
return new Resource($transaction->fresh());
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param Transaction $transaction
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(Transaction $transaction)
|
|
{
|
|
try {
|
|
$this->dispatch(new DeleteTransaction($transaction));
|
|
|
|
return $this->noContent();
|
|
} catch(\Exception $e) {
|
|
$this->errorUnauthorized($e->getMessage());
|
|
}
|
|
}
|
|
}
|