<?php

namespace Database\Seeders;

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

class MembersSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Créer l'admin
        User::firstOrCreate(
            ['email' => 'admin@gie.com'],
            [
                'name' => 'Administrateur',
                'first_name' => 'Admin',
                'last_name' => 'GIE',
                'email' => 'admin@gie.com',
                'password' => Hash::make('password'),
                'phone' => '+221 78 596 1959',
                'cni' => 'CI123456789',
                'gender' => 'homme',
                'nationality' => 'Sénégalaise',
                'residence' => 'Dakar',
                'address' => 'Dakar/Keur massar cité Apix',
                'role' => 'admin',
                'status' => 'active',
            ]
        );

        // Créer 5 membres avec statut "pending"
        $members = [
            [
                'name' => 'Diallo',
                'first_name' => 'Amadou',
                'last_name' => 'Diallo',
                'email' => 'amadou.diallo@example.com',
                'password' => Hash::make('password'),
                'phone' => '+221 77 123 4567',
                'cni' => 'CI987654321',
                'gender' => 'homme',
                'nationality' => 'Sénégalaise',
                'residence' => 'Thiès',
                'address' => 'Thiès, Avenue Cheikh Anta Diop, Résidence Les Palmiers',
                'role' => 'membre',
                'status' => 'pending',
            ],
            [
                'name' => 'Ndiaye',
                'first_name' => 'Fatou',
                'last_name' => 'Ndiaye',
                'email' => 'fatou.ndiaye@example.com',
                'password' => Hash::make('password'),
                'phone' => '+221 76 234 5678',
                'cni' => 'CI876543210',
                'gender' => 'femme',
                'nationality' => 'Sénégalaise',
                'residence' => 'Saint-Louis',
                'address' => 'Saint-Louis, Quartier Nord, Rue des Pêcheurs',
                'role' => 'membre',
                'status' => 'pending',
            ],
            [
                'name' => 'Ba',
                'first_name' => 'Moussa',
                'last_name' => 'Ba',
                'email' => 'moussa.ba@example.com',
                'password' => Hash::make('password'),
                'phone' => '+221 70 345 6789',
                'cni' => 'CI765432109',
                'gender' => 'homme',
                'nationality' => 'Sénégalaise',
                'residence' => 'Kaolack',
                'address' => 'Kaolack, Cité des Parcelles Assainies, Lot 45',
                'role' => 'membre',
                'status' => 'pending',
            ],
            [
                'name' => 'Sall',
                'first_name' => 'Aissatou',
                'last_name' => 'Sall',
                'email' => 'aissatou.sall@example.com',
                'password' => Hash::make('password'),
                'phone' => '+221 78 456 7890',
                'cni' => 'CI654321098',
                'gender' => 'femme',
                'nationality' => 'Sénégalaise',
                'residence' => 'Ziguinchor',
                'address' => 'Ziguinchor, Quartier Escale, Avenue de la République',
                'role' => 'membre',
                'status' => 'pending',
            ],
            [
                'name' => 'Seck',
                'first_name' => 'Ibrahima',
                'last_name' => 'Seck',
                'email' => 'ibrahima.seck@example.com',
                'password' => Hash::make('password'),
                'phone' => '+221 77 567 8901',
                'cni' => 'CI543210987',
                'gender' => 'homme',
                'nationality' => 'Sénégalaise',
                'residence' => 'Rufisque',
                'address' => 'Rufisque, Cité Keur Serigne Fall, Villa 12',
                'role' => 'membre',
                'status' => 'pending',
            ],
        ];

        foreach ($members as $member) {
            User::firstOrCreate(
                ['email' => $member['email']],
                $member
            );
        }
    }
}

