<?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 ['id' => $this->id, 'reference' => $this->reference, 'room' => new RoomResource($this->whenLoaded('room')), 'user' => new UserResource($this->whenLoaded('user')), 'booking_date' => $this->booking_date?->format('Y-m-d'), 'start_time' => substr($this->start_time, 0, 5), 'end_time' => substr($this->end_time, 0, 5), 'purpose' => $this->purpose, 'status' => $this->status, 'created_at' => $this->created_at?->toISOString(), 'rejection_reason' => $this->rejection_reason]; } }
