<?php

namespace Modules\HR\Models\Traits;

use Modules\HR\Models\SalaryComponent;

trait GenerateSalaryComponentCodeTraits
{
    protected function generateSalaryComponentCode(): string
    {
        do {
            $code = 'SC-' . random_int(100000, 999999);
        } while (SalaryComponent::where('code', $code)->exists());

        return $code;
    }
}
