mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Voucherify phase 2
This commit is contained in:
@@ -5,10 +5,11 @@ namespace App\Classes\Modules\Vouchers\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Vouchers\Services\ValidatesVoucher;
|
||||
use App\Classes\Modules\Vouchers\Services\Voucherify\ValidatesVoucherifyVoucher;
|
||||
use App\Classes\Modules\Vouchers\DataTransferObjects\ValidateVoucherifyVoucherObject;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use ErrorException;
|
||||
use App\Models\Booking;
|
||||
|
||||
class ValidateVoucherLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -22,15 +23,16 @@ class ValidateVoucherLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ValidatesVoucher */
|
||||
private $validatesVoucher;
|
||||
/** @var ValidatesVoucherifyVoucher */
|
||||
private $validatesVoucherifyVoucher;
|
||||
|
||||
/**
|
||||
* ValidateVoucherLogic constructor.
|
||||
* @param ValidatesVoucherifyVoucher $validatesVoucherifyVoucher
|
||||
*/
|
||||
public function __construct(ValidatesVoucher $validatesVoucher)
|
||||
public function __construct(ValidatesVoucherifyVoucher $validatesVoucherifyVoucher)
|
||||
{
|
||||
$this->validatesVoucher = $validatesVoucher;
|
||||
$this->validatesVoucherifyVoucher = $validatesVoucherifyVoucher;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,9 +42,12 @@ class ValidateVoucherLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$result = $this->validatesVoucher->execute($request->input('voucherCode'), null, null);
|
||||
$booking = Booking::find($request->input('itemId'));
|
||||
$employee = $booking->company->employees()->first();
|
||||
|
||||
$validateVoucherifyVoucherObject = new ValidateVoucherifyVoucherObject($booking->company_id, $request->input('voucherCode'), $request->input('amount'), $employee);
|
||||
$result = $this->validatesVoucherifyVoucher->execute($validateVoucherifyVoucherObject);
|
||||
return $this->response(['data' => $result]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user