<?php

namespace App\Filament\Tenant\Resources\WorkOrderResource\Pages;

use App\Filament\Tenant\Resources\WorkOrderResource;
use App\Models\Tenant\WorkOrder;
use App\Tenancy\TenantManager;
use Filament\Resources\Pages\CreateRecord;

class CreateWorkOrder extends CreateRecord
{
    protected static string $resource = WorkOrderResource::class;

    protected function mutateFormDataBeforeCreate(array $data): array
    {
        $companyId = app(TenantManager::class)->currentId();
        $data['number'] = WorkOrder::generateNumber($companyId);
        return $data;
    }
}
