<?php

namespace Database\Seeders;

use App\Models\Customer;
use Illuminate\Database\Seeder;

class CustomerSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Beberapa pelanggan default
        $defaults = [
            [
                'name' => 'John Doe',
                'phone_number' => '081234567890',
                'address' => 'Jl. Raya No. 123, Jakarta Selatan',
            ],
            [
                'name' => 'Jane Smith',
                'phone_number' => '082233445566',
                'address' => 'Jl. Merdeka No. 45, Bandung',
            ],
            [
                'name' => 'Toko Sembako Makmur',
                'phone_number' => '081298765432',
                'address' => 'Jl. Pasar Baru No. 10, Surabaya',
            ],
        ];

        foreach ($defaults as $data) {
            Customer::firstOrCreate(
                ['phone_number' => $data['phone_number']],
                [
                    'name' => $data['name'],
                    'address' => $data['address'],
                ]
            );
        }

        // Tambah beberapa pelanggan random
        Customer::factory()->count(10)->create();
    }
}
