<?php

declare(strict_types=1);

namespace Maestro\Core\Modules\HourRegistration\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Maestro\Core\Modules\HourRegistration\Models\HourTimesheetWeek;

/** @mixin HourTimesheetWeek */
class HourTimesheetWeekResource extends JsonResource
{
    /**
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'user_id' => $this->user_id,
            'week_start' => $this->week_start->toDateString(),
            'workflow_status' => $this->workflow_status->value,
            'submitted_at' => $this->submitted_at,
            'lines' => HourTimesheetLineResource::collection($this->whenLoaded('lines')),
        ];
    }
}
