<?php

namespace Modules\Inventory\Transformers;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Modules\Accounts\Transformers\CoaResource;

class SupplierResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id'              => $this->id,
            'name'            => $this->name,
            'phone'           => $this->phone,
            'address'         => $this->address,
            'account_id'      => $this->account_id,
            'payable_account' => new CoaResource($this->whenLoaded('account')),
            'status'       => $this->status,
        ];
    }
}
