<?php

namespace App\Http\Resources\Opportunity;

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

class ActivityResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'title' => $this->title,
            'description' => $this->description,
            'scheduled_at' => Carbon::parse($this->scheduled_at)->format('Y-m-d H:i:s'),
            'completed_at' => $this->completed_at,
            'state_activity' => $this->state_activity,
            'type_activity_id' => $this->type_activity_id,
            'type_activity' => $this->type_activity->name,

            'opportunity_id' => $this->opportunity_id,
            'assigned_to' => $this->assigned_to,
            'name_assigned'=>$this->user->name,
            'entity_status' => $this->entity_status,
            'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
        ];
    }
}
