*/ public function toArray(Request $request): array { // This resource handles both Eloquent models and raw arrays from EmailService if (is_array($this->resource)) { return $this->resource; } return [ 'id' => $this->id, 'organisation_id' => $this->organisation_id, 'type' => $this->type instanceof \App\Enums\EmailTemplateType ? $this->type->value : $this->type, 'label' => $this->type instanceof \App\Enums\EmailTemplateType ? $this->type->label() : $this->type, 'subject' => $this->subject, 'heading' => $this->heading, 'body_text' => $this->body_text, 'button_text' => $this->button_text, 'is_custom' => true, 'created_at' => $this->created_at->toIso8601String(), 'updated_at' => $this->updated_at->toIso8601String(), ]; } }