Files
exchange-2.0/app/Classes/Modules/Vouchers/ControllersLogic/UpdateVoucherEndDateLogic.php
T

53 lines
1.6 KiB
PHP

<?php
namespace App\Classes\Modules\Vouchers\ControllersLogic;
use App\Classes\Modules\Vouchers\DataTransferObjects\UpdateVoucherEndDateObject;
use App\Classes\Modules\Vouchers\Services\UpdatesVoucherEndDate;
use App\Classes\Modules\Vouchers\Standards\Rules\CanUpdateVoucherEndDate;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class UpdateVoucherEndDateLogic extends AbstractControllerLogic
{
/** @var UpdatesVoucherEndDate */
private $updatesVoucherEndDate;
/** @var CanUpdateVoucherEndDate */
private $canUpdateVoucherEndDate;
/**
* UpdateVoucherEndDateLogic constructor.
* @param UpdatesVoucherEndDate $updatesVoucherEndDate
* @param CanUpdateVoucherEndDate $canUpdateVoucherEndDate
*/
public function __construct(UpdatesVoucherEndDate $updatesVoucherEndDate, CanUpdateVoucherEndDate $canUpdateVoucherEndDate)
{
$this->updatesVoucherEndDate = $updatesVoucherEndDate;
$this->canUpdateVoucherEndDate = $canUpdateVoucherEndDate;
}
protected function notification(): array
{
return [
'title' => 'Updated Voucher End Date',
'message' => 'The selected voucher end date has been updated.'
];
}
public function logic(Request $request): JsonResponse
{
$object = new UpdateVoucherEndDateObject(
$request->input('id'),
$request->input('end_date')
);
$this->canUpdateVoucherEndDate->passes($object);
$voucher = $this->updatesVoucherEndDate->execute($object);
return $this->response([]);
}
}