<?php

namespace Tps\Hhm\Classes;

use Illuminate\Http\Resources\Json\JsonResource;

class ContentResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $locale = $request->get('locale');

        return [
            'id' => $this->id,
            'content' => $this->getAttributeTranslated('content', $locale),
            'type' => $this->type
        ];
    }
}
