<?php

namespace App\Http\Resources\Promotions;

use Illuminate\Http\Resources\Json\JsonResource;

class PromotionAuditLogResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'id' => (int) ($this->id ?? 0),
            'promotion_id' => $this->promotion_id ? (int) $this->promotion_id : null,
            'student_id' => $this->student_id ? (int) $this->student_id : null,
            'user_id' => $this->user_id ? (int) $this->user_id : null,
            'action_type' => $this->action_type,
            'field' => $this->field,
            'old_value' => $this->old_value,
            'new_value' => $this->new_value,
            'notes' => $this->notes,
            'performed_at' => optional($this->performed_at)->toDateTimeString(),
            'created_at' => optional($this->created_at)->toDateTimeString(),
        ];
    }
}
