<?php

namespace Database\Factories;

use App\Models\Group;
use App\Models\Number;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Number>
 */
class NumberFactory extends Factory
{
    protected $model = Number::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $prefixes = ['017', '013', '019', '014', '018', '016', '015'];
        $prefix = fake()->randomElement($prefixes);
        $randomDigits = str_pad((string) fake()->unique()->numberBetween(10000000, 99999999), 8, '0', STR_PAD_LEFT);
        $phoneNumber = $prefix . $randomDigits;

        $notesList = [
            'Preferred contact for campaigns',
            'VIP Account holder',
            'Registered from mobile app',
            'Subscribed to SMS alerts',
            'Branch client',
            'Corporate contact',
            'Standard priority contact',
            null,
        ];

        return [
            'user_id' => User::query()->value('id') ?? 1,
            'group_id' => Group::query()->inRandomOrder()->value('id') ?? 1,
            'name' => fake()->name(),
            'number' => $phoneNumber,
            'notes' => fake()->randomElement($notesList),
        ];
    }
}
