<?php

namespace Database\Seeders;

use App\Models\User;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;

class RolesAndAdminSeeder extends Seeder
{
    public function run(): void
    {
        $admin = Role::findOrCreate('admin');
        Role::findOrCreate('member');

        $user = User::firstOrCreate(
            ['email' => 'admin@moneywise.co.ke'],
            [
                'name' => 'Money-Wise Admin',
                'password' => 'ChangeMe!2026',
                'email_verified_at' => now(),
            ]
        );

        $user->assignRole($admin);
    }
}
