<?php


namespace API\Category\Http\Resources;


use Illuminate\Http\Resources\Json\JsonResource;
use API\Article\Http\Resources\ArticleResource;

class CategoryResource2 extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'title' => $this->name,
            'name' => $this->name,
            'slug' => $this->slug,
            'url' => $this->url,
            'parent' => new CategoryResource2($this->parent2),
            'products' => $this->products,
            'group_products' => $this->group_products,
            'media' => [
                "alt"=>$this->media->alt ?? null,
                "url"=>$this->media->url ?? null,
            ],

        ];
    }
}
