<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\ZapPageFormFields;
use App\Http\Resources\ZapPageFormButtons;


class ZapPage extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return [
            'slug' => $this->slug,
            'title' => $this->title,
            'sub_title' => $this->sub_title,
            'description' => $this->description,
            'image' => $this->image,
            'content' => $this->content,
            'is_back_button' => $this->is_back_button,
            'fields' => ZapPageFormFields::collection($this->zapPageFormFields),
            'buttons' => ZapPageFormButtons::collection($this->zapPageFormButtons),
        ];
    }
}
