<?php

namespace App\Http\Resources;

use App\Classes\Modules\Segments\Services\ConvertsConstantDetailsToResource;
use Illuminate\Http\Resources\Json\JsonResource;

class ConstantResource extends JsonResource
{

    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'reference' => $this->reference,
            'detail' => (App()->make(ConvertsConstantDetailsToResource::class))->execute($this->resource)
        ];
    }
}
