initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class BookingResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'slot_start' => $this->slot_start?->toIso8601String(),
|
||||
'slot_end' => $this->slot_end?->toIso8601String(),
|
||||
'booking_fee' => (float) $this->booking_fee,
|
||||
'reserved_amount' => (float) $this->reserved_amount,
|
||||
'penalty_amount' => (float) $this->penalty_amount,
|
||||
'status' => $this->status,
|
||||
'cancelled_at' => $this->cancelled_at?->toIso8601String(),
|
||||
'penalty_applied_at' => $this->penalty_applied_at?->toIso8601String(),
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
'machine' => new MachineResource($this->whenLoaded('machine')),
|
||||
'user' => new UserResource($this->whenLoaded('user')),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user