<?php

namespace Modules\Travel\Transformers;

use Illuminate\Http\Resources\Json\JsonResource;

class TravelExpenseLogResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id'                  => $this->id,
            'expense_category_id' => $this->expense_category_id,
            'expense_category'    => @$this->expenseCategory->name,
            'amount'              => $this->amount,
            'file'                => $this->file_id ? uploaded_asset($this->file_id) : null,
            'remark'              => $this->remark,
        ];
    }
}
