mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'dillon/10-edit-bank-details' into dillon/66-payment-bank-details
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\BookingResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanUpdateBooking;
|
||||
use App\Classes\Modules\Bookings\Services\UpdatesBooking;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateBookingRecipientLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Booking',
|
||||
'message' => 'You have successfully updated the Booking'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateBooking */
|
||||
private $canUpdateBooking;
|
||||
|
||||
/** @var UpdatesBooking */
|
||||
private $updatesBooking;
|
||||
|
||||
/** @var FetchesBooking */
|
||||
private $fetchesBooking;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateBookingRecipientLogic constructor.
|
||||
* @param CanUpdateBooking $canUpdateBooking
|
||||
* @param UpdatesBooking $updatesBooking
|
||||
* @param FetchesBooking $fetchesBooking
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateBooking $canUpdateBooking,
|
||||
UpdatesBooking $updatesBooking,
|
||||
FetchesBooking $fetchesBooking
|
||||
)
|
||||
{
|
||||
$this->canUpdateBooking = $canUpdateBooking;
|
||||
$this->updatesBooking = $updatesBooking;
|
||||
$this->fetchesBooking = $fetchesBooking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$booking = $this->fetchesBooking->execute(['id' => $request->route('id')]);
|
||||
|
||||
|
||||
$booking_object = new BookingObject(
|
||||
$booking->service_id,
|
||||
$request->input('transferable_bank_id', $booking->transferable_bank_id),
|
||||
$booking->marking,
|
||||
$booking->fix_amount,
|
||||
$booking->fix_currency_id,
|
||||
$booking->convertible_currency_id,
|
||||
$booking->conversion_currency_id
|
||||
);
|
||||
$this->canUpdateBooking->passes($booking_object);
|
||||
$booking = $this->updatesBooking->execute($booking, $booking_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new BookingResource($booking));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bookings;
|
||||
|
||||
use App\Classes\Modules\Bookings\ControllersLogic\UpdateBookingRecipientLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateBookingRecipientController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateBookingRecipientLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateBookingRecipientLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user