<?php

namespace App\Resources;

use Wibiesana\Padi\Core\Resource;

class SarprasPetugaResource extends Resource
{
    public function toArray($request): array
    {
        return [
            'id' => $this->id,
            'user_id' => $this->user_id,
            'nip' => $this->nip,
            'nama_lengkap' => $this->nama_lengkap,
            'jabatan' => $this->jabatan,
            'kontak' => $this->kontak,

            // Relations
            'user' => $this->whenLoaded('user'),

            // Flattened Fields
            'user_name' => $this->user['username'] ?? null,

        ];
    }
}