<?php

namespace Database\Seeders;

use App\Models\SecurityManagement\Role;
use App\Models\UserManagement\Admin;
use App\Models\UserManagement\User;
use App\Models\UserManagement\UserType;
use Illuminate\Database\Seeder;;

class AdminSeeder extends Seeder{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run(){

        //Admin::factory(10)->create(); // valider en BD

        // gets all permissions via Gate::before rule; see AuthServiceProvider

        $admins = [
            [
                'first_name' => 'Joel',
                'last_name' => 'Simo',
                'username' => 'jsimo',
                'email' => 'joelsimooverride@gmail.com',
                'phone' => "2376691894015",
                'password' => bcrypt('123456'),
                'email_verified_at' => now(),
            ],
            [
                'first_name' => 'Celestine',
                'last_name' => 'Bodi Lufong',
                'username' => 'cbodi',
                'email' => 'cbodi2014@gmail.com',
                'phone' => "237674635192",
                'password' => bcrypt('admin'),
                'email_verified_at' => now(),
            ],
            [
                'first_name' => 'Admin',
                'last_name' => 'Account',
                'username' => 'admin',
                'email' => 'admin-acoount@app.com',
                'phone' => null,
                'password' => bcrypt('admin'),
                'email_verified_at' => now(),
            ],
        ];

        if (filled($admins)){
            Admin::upsert($admins,['username']);
            $admins = Admin::whereIn('username',array_column($admins,"username"))->get();
            $admins->map->assignRole(Role::SUPER_ADMIN);

            echo ("All Admin Users created.\n\n");
        }


    }
}
