| 1234567891011121314151617181920212223242526272829 |
- <?php
- namespace App\Http\Resources;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- class ContactMessageResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @return array<string, mixed>
- */
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'sender_name' => $this->name,
- 'sender_email' => $this->email,
- 'message_body' => $this->message,
- 'submitted_at' => $this->created_at->format('Y-m-d H:i:s'),
-
- 'category' => new CategoryResource($this->whenLoaded('category')),
- 'status' => new StatusResource($this->whenLoaded('status')),
- 'notes' => NoteResource::collection($this->whenLoaded('notes')),
- ];
- }
- }
|