<?php

namespace App\Http\Resources\Api\V1;

use App\Domain\Website\Models\WebsitePage;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/** @mixin WebsitePage */
class WebsitePageResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'website_id' => $this->website_id,
            'slug' => $this->slug,
            'title' => $this->title,
            'page_type' => $this->page_type->value,
            'status' => $this->status->value,
            'meta' => $this->meta,
            'sort_order' => $this->sort_order,
            'published_at' => $this->published_at?->toISOString(),
            'grapes_json' => $this->grapes_json,
            'exported_html' => $this->exported_html,
            'created_at' => $this->created_at->toISOString(),
            'updated_at' => $this->updated_at->toISOString(),
        ];
    }
}
