<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class AirShipmentItemPriceResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $object = $this->resource;
        $detailsArray = (array)json_decode($object['details']);

        return [
            'name' => $detailsArray['name'],
            'details' => $object['details'],
        ];
    }
}
