Admin Workflow - Fix Tested Issues

This commit is contained in:
Dillon Ngo
2025-01-11 04:02:25 +08:00
parent e589273776
commit 362668fc50
4 changed files with 36 additions and 23 deletions
@@ -6,7 +6,9 @@ namespace App\Classes\Modules\Questionnaires\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Questionnaires\Standards\Rules\CanFetchQuestion;
use App\Classes\ValueObjects\Constants\BookingAttributeNames;
use App\Classes\Modules\Bookings\Services\FetchesBooking;
use App\Http\Resources\BookingBaseResource;
use App\Http\Resources\BookingResource;
use App\Models\Booking;
use ErrorException;
use Illuminate\Http\JsonResponse;
@@ -28,14 +30,18 @@ class FetchAdminWFModelAttributesLogic extends AbstractControllerLogic
/** @var CanFetchQuestion */
private $canFetchQuestion;
/** @var FetchesBooking */
private $fetchesBooking;
/**
* FetchAdminWFModelAttributesLogic constructor.
* @param CanFetchQuestion $canFetchQuestion
* @param FetchesBooking $fetchesBooking
*/
public function __construct(CanFetchQuestion $canFetchQuestion)
public function __construct(CanFetchQuestion $canFetchQuestion, FetchesBooking $fetchesBooking)
{
$this->canFetchQuestion = $canFetchQuestion;
$this->fetchesBooking = $fetchesBooking;
}
@@ -48,7 +54,8 @@ class FetchAdminWFModelAttributesLogic extends AbstractControllerLogic
{
$this->canFetchQuestion->passes();
$booking = Booking::find($request->route('booking_id'));
// $booking = Booking::find($request->route('booking_id'));
$booking = $this->fetchesBooking->execute(['id' => $request->route('booking_id'), 'with_transactions' => true, 'order_by_id_desc' => true]);
if (!$booking) {
return responseJson(null, 'No booking found', 404);
@@ -60,16 +67,16 @@ class FetchAdminWFModelAttributesLogic extends AbstractControllerLogic
->map(fn ($attr) => $attr->only(['id', 'value']));
$transaction = $booking->bills()->first(); //cief todo: 74 - more than 1 record?
return responseJson([
'booking' => $booking,
'booking_attributes' => $attributes,
'reference' =>$transaction->owner->owner->marking,
'marking' => $transaction->owner->owner->company->reference,
'currency_rate' => $transaction->currency_rate,
'total_amount' =>$transaction->currency->short_code . ' ' . number_format((float)$transaction->amount, 2, '.', '')
]);
// return responseJson([
// 'booking' => $booking,
// 'booking_attributes' => $attributes,
// 'reference' =>$transaction->owner->owner->marking,
// 'marking' => $transaction->owner->owner->company->reference,
// 'currency_rate' => $transaction->currency_rate,
// 'total_amount' =>$transaction->currency->short_code . ' ' . number_format((float)$transaction->amount, 2, '.', '')
// ]);
return $this->resourceResponse(new BookingBaseResource($booking));
return $this->resourceResponse(new BookingResource($booking));
}
}