<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class UiLandingHeading extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    #[\Override]
    public function toArray($request)
    {
        return [
            'title' => $this->resource->subContent->where('slug', 'title')->first()?->content,
            'subtitle' => $this->resource->subContent->where('slug', 'subtitle')->first()?->content,
            'description' => $this->resource->subContent->where('slug', 'description')->first()?->content,
        ];
    }
}
