<?php

namespace Modules\Cms\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class ArticleBaseResource extends JsonResource
{

    public function toArray($request): array
    {
        return [
            'article_id'  => $this->id,
            'title'       => $this->title,
            //                    'sub_title'   => $this->sub_title,
            'description' => $this->description,
            //                    'slug'        => $this->slug,
            'categories'  => CategoryBaseResource::collection($this->categories),
            'tags'        => TagResource::collection($this->tags),
            'cover'       => $this->cover_url,
            'pictures'    => $this->pictures_url,
            'clicks'      => $this->clicks,
            'favorites'   => $this->favorites()->count(),
            'subscribes'  => $this->subscribers()->count(),
            'created_at'  => (string) $this->created_at,
        ];
    }

}