<?php

namespace Modules\Chip\Resources\Api;

use Illuminate\Http\Resources\Json\JsonResource;

class ChipResource extends JsonResource
{

    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $return = [
            'id' => (int) $this->id,
            'title' => $this->currentDescription->title ?? "",
            'count' => (int) $this->count,
            'cost' => (double) $this->cost,
            'image' => $this->image ? asset($this->image) : null,
        ];

        return $return;
    }

}
