<?php

namespace TPS\Birzha\Classes;

use Illuminate\Http\Resources\Json\JsonResource;
 
class BlogPostResource 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,
            'title' => $this->getAttributeTranslated('title', $locale),
            'published_at' => $this->published_at->format('d.m.Y'),
            'featured_images' => ImageResource::collection($this->featured_images),
            'content_html' => $this->getAttributeTranslated('content_html', $locale)
        ];
    }
}