'Retrieved Model Attributes for Admin Workflow ', 'message' => 'You have successfully retrieved Model Attributes for Admin Workflow' ]; } /** @var CanFetchQuestion */ private $canFetchQuestion; /** * FetchAdminWFModelAttributesLogic constructor. * @param CanFetchQuestion $canFetchQuestion */ public function __construct(CanFetchQuestion $canFetchQuestion) { $this->canFetchQuestion = $canFetchQuestion; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { $this->canFetchQuestion->passes(); $booking = Booking::find($request->route('booking_id')); if (!$booking) { return responseJson(null, 'No booking found', 404); } $attributes = $booking->modelAttributes() ->where('name', BookingAttributeNames::ORDER_REFERENCE_NO) ->get(['id', 'value']) ->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 $this->resourceResponse(new BookingBaseResource($booking)); } }