Files
shipping-portal/app/Classes/Modules/Transactions/ControllersLogic/WaiveTransactionLogic.php
T

63 lines
2.0 KiB
PHP

<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\DataTransferObjects\WaiveTransactionObject;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionIsWaived;
use App\Classes\Modules\Transactions\Standards\Rules\CanWaiveTransaction;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class WaiveTransactionLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Waive Transaction',
'message' => 'You have successfully waived the transaction'
];
}
/** @var FetchesTransaction */
private $fetchesTransaction;
/** @var UpdatesTransactionIsWaived */
private $updatesTransactionIsWaived;
/** @var CanWaiveTransaction */
private $canWaiveTransaction;
/**
* WaiveTransactionLogic constructor.
* @param FetchesTransaction $fetchesTransaction
* @param UpdatesTransactionIsWaived $updatesTransactionIsWaived
* @param CanWaiveTransaction $canWaiveTransaction
*/
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionIsWaived $updatesTransactionIsWaived, CanWaiveTransaction $canWaiveTransaction)
{
$this->fetchesTransaction = $fetchesTransaction;
$this->updatesTransactionIsWaived = $updatesTransactionIsWaived;
$this->canWaiveTransaction = $canWaiveTransaction;
}
public function logic(Request $request) : JsonResponse
{
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
$object = new WaiveTransactionObject($transaction->id, $transaction->bill_no, $transaction->type);
$this->canWaiveTransaction->passes($object);
$this->updatesTransactionIsWaived->execute($transaction);
return $this->response([]);
}
}