<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class UserOperationResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     */
    public function toArray(Request $request): array
    {
        return [
            'id'   => $this->id,
            'user' => [
                'id' => $this->user?->id,
                'name' => $this->user?->name,
            ],
            'project' => [
                'id' => $this->project?->id,
                'name' => $this->project?->name,
                'status' => $this->project?->status,
            ],
            'finals' => [
                'designation_tech_skills' => $this->userOperationFinal?->designation_tech_skills,
                'power_influence' => $this->userOperationFinal?->power_influence,
                'interpersonal_relationship_experience' => $this->userOperationFinal?->interpersonal_relationship_experience,
                'weightage' => $this->userOperationFinal?->weightage,
                'front_weight' => $this->userOperationFinal?->front_weight
            ],
            'updated_at' => $this->updated_at?->toDateTimeString(),
        ];
    }
}
