mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-23 06:24:10 +00:00
62 lines
1.8 KiB
PHP
62 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
|
use App\Classes\Modules\Transactions\Standards\Rules\CanFetchTransaction;
|
|
use App\Http\Resources\TransactionWithStorageResource;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class FetchTransactionLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Fetched Transaction',
|
|
'message' => 'You have successfully retrieved a Transaction'
|
|
];
|
|
}
|
|
|
|
/** @var CanFetchTransaction */
|
|
private $canFetchTransaction;
|
|
|
|
/** @var FetchesTransaction */
|
|
private $fetchesTransaction;
|
|
|
|
/**
|
|
* FetchTransactionLogic constructor.
|
|
* @param CanFetchTransaction $canFetchTransaction
|
|
* @param FetchesTransaction $fetchesTransaction
|
|
*/
|
|
public function __construct(CanFetchTransaction $canFetchTransaction, FetchesTransaction $fetchesTransaction)
|
|
{
|
|
$this->canFetchTransaction = $canFetchTransaction;
|
|
$this->fetchesTransaction = $fetchesTransaction;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$this->canFetchTransaction->passes();
|
|
|
|
$query = $this->fetchesTransaction->execute(['id' => $request->route('transaction_id')]);
|
|
|
|
if($request->input('storages')){
|
|
$query->storages = $request->input('storages'); //from middleware
|
|
}
|
|
|
|
return $this->resourceResponse(new TransactionWithStorageResource($query));
|
|
}
|
|
}
|