<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\User;
use Illuminate\Support\Facades\Hash;

class KurirSeeder extends Seeder
{
    public function run()
    {
        $kurirs = [
            [
                'name' => 'Yanto Kurir',
                'email' => 'yantokurir@gmail.com',
                'password' => Hash::make('123'),
                'no_hp' => '081234567891',
                'role' => 'kurir'
            ],
            [
                'name' => 'Isan Kurir',
                'email' => 'isankurir@gmail.com',
                'password' => Hash::make('123'),
                'no_hp' => '081234567892',
                'role' => 'kurir'
            ],
            [
                'name' => 'Mamat Kurir',
                'email' => 'mamatkurir@gmail.com',
                'password' => Hash::make('123'),
                'no_hp' => '081234567893',
                'role' => 'kurir'
            ],
            [
                'name' => 'Memet Kurir',
                'email' => 'memetkurir@gmail.com',
                'password' => Hash::make('123'),
                'no_hp' => '081234567894',
                'role' => 'kurir'
            ],
            [
                'name' => 'Deni Kurir',
                'email' => 'denikurir@gmail.com',
                'password' => Hash::make('123'),
                'no_hp' => '081234567895',
                'role' => 'kurir'
            ],
            [
                'name' => 'Eka Kurir',
                'email' => 'ekakurir@gmail.com',
                'password' => Hash::make('123'),
                'no_hp' => '081234567896',
                'role' => 'kurir'
            ],
            [
                'name' => 'Yanti Kurir',
                'email' => 'yantikurir@gmail.com',
                'password' => Hash::make('123'),
                'no_hp' => '081234567897',
                'role' => 'kurir'
            ],
            [
                'name' => 'Gita Kurir',
                'email' => 'gitakurir@gmail.com',
                'password' => Hash::make('123'),
                'no_hp' => '081234567898',
                'role' => 'kurir'
            ],
            [
                'name' => 'Yuni Kurir',
                'email' => 'yunikurir@gmail.com',
                'password' => Hash::make('123'),
                'no_hp' => '081234567899',
                'role' => 'kurir'
            ],
            [
                'name' => 'Indah Kurir',
                'email' => 'indahkurir@gmail.com',
                'password' => Hash::make('123'),
                'no_hp' => '081234567900',
                'role' => 'kurir'
            ],
        ];

        foreach ($kurirs as $kurir) {
            // Gunakan updateOrCreate untuk menghindari duplikasi email
            User::updateOrCreate(
                ['email' => $kurir['email']],
                $kurir
            );
        }

        $this->command->info('10 data kurir berhasil ditambahkan!');
    }
}