Laravel Vapor - Fix a 504 error at /bookings/urgent page

This commit is contained in:
Dillon Ngo
2024-10-15 15:40:49 +08:00
parent 10b0e2340c
commit c9d3bc4b93
2 changed files with 30 additions and 1 deletions
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Resources;
use App\Models\Booking;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
class DocumentForTransactionUrgentResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
// 'reference' => $this->reference,
// 'status' => (int) $this->status,
// 'document_type' => $this->document_type,
// 'owner' => $this->relationLoaded('owner') ? ($this->owner instanceof Booking ? new BookingResource($this->owner) : new CompanyResource($this->owner)) : null,
// 'files' => FileResource::collection($this->files),
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A')
];
}
}
@@ -52,7 +52,7 @@ class TransactionUrgentResource extends JsonResource
// 'currency_rate' => (double) $this->currency_rate,
// 'status' => (int) $this->status,
//'details' => TransactionDetailResource::collection($this->transactionDetails),
'documents' => new DocumentResource($this->documents()->first()),
'documents' => new DocumentForTransactionUrgentResource($this->documents()->first()),
//'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first())),
//'transaction_refunds' => TransactionResource::collection($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get())),
//'refunded_amount' => $this->booking ? floatval((App()->make(CalculatesBookingRefundAmount::class))->calculateRefundAmount($this->resource, $this->booking->fix_currency_id)) : null,