<?php

namespace Database\Seeders;

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

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {

        \App\Models\Admin::factory(1)->create();

        $role = Role::create(['name' => 'admin', 'guard_name' => 'admin']);

        Permission::create(['name' => 'add_admin', 'guard_name' => 'admin', 'group_name' => 'Admins']);
        $role->givePermissionTo('add_admin');
        Permission::create(['name' => 'edit_admin', 'guard_name' => 'admin', 'group_name' => 'Admins']);
        $role->givePermissionTo('edit_admin');
        Permission::create(['name' => 'delete_admin', 'guard_name' => 'admin', 'group_name' => 'Admins']);
        $role->givePermissionTo('delete_admin');
        Permission::create(['name' => 'view_admin', 'guard_name' => 'admin', 'group_name' => 'Admins']);
        $role->givePermissionTo('view_admin');
        Permission::create(['name' => 'add_role', 'guard_name' => 'admin', 'group_name' => 'Roles']);
        $role->givePermissionTo('add_role');
        Permission::create(['name' => 'edit_role', 'guard_name' => 'admin', 'group_name' => 'Roles']);
        $role->givePermissionTo('edit_role');
        Permission::create(['name' => 'delete_role', 'guard_name' => 'admin', 'group_name' => 'Roles']);
        $role->givePermissionTo('delete_role');
        Permission::create(['name' => 'view_role', 'guard_name' => 'admin', 'group_name' => 'Roles']);
        $role->givePermissionTo('view_role');
        Permission::create(['name' => 'add_extension', 'guard_name' => 'admin', 'group_name' => 'Extensions']);
        $role->givePermissionTo('add_extension');
        Permission::create(['name' => 'edit_extension', 'guard_name' => 'admin', 'group_name' => 'Extensions']);
        $role->givePermissionTo('edit_extension');
        Permission::create(['name' => 'delete_extension', 'guard_name' => 'admin', 'group_name' => 'Extensions']);
        $role->givePermissionTo('delete_extension');
        Permission::create(['name' => 'view_extension', 'guard_name' => 'admin', 'group_name' => 'Extensions']);
        $role->givePermissionTo('view_extension');
        Permission::create(['name' => 'add_position', 'guard_name' => 'admin', 'group_name' => 'Positions']);
        $role->givePermissionTo('add_position');
        Permission::create(['name' => 'edit_position', 'guard_name' => 'admin', 'group_name' => 'Positions']);
        $role->givePermissionTo('edit_position');
        Permission::create(['name' => 'delete_position', 'guard_name' => 'admin', 'group_name' => 'Positions']);
        $role->givePermissionTo('delete_position');
        Permission::create(['name' => 'view_position', 'guard_name' => 'admin', 'group_name' => 'Positions']);
        $role->givePermissionTo('view_position');
        Permission::create(['name' => 'add_prefix', 'guard_name' => 'admin', 'group_name' => 'Prefixes']);
        $role->givePermissionTo('add_prefix');
        Permission::create(['name' => 'edit_prefix', 'guard_name' => 'admin', 'group_name' => 'Prefixes']);
        $role->givePermissionTo('edit_prefix');
        Permission::create(['name' => 'delete_prefix', 'guard_name' => 'admin', 'group_name' => 'Prefixes']);
        $role->givePermissionTo('delete_prefix');
        Permission::create(['name' => 'view_prefix', 'guard_name' => 'admin', 'group_name' => 'Prefixes']);
        $role->givePermissionTo('view_prefix');
        Permission::create(['name' => 'add_sector', 'guard_name' => 'admin', 'group_name' => 'Sectors']);
        $role->givePermissionTo('add_sector');
        Permission::create(['name' => 'edit_sector', 'guard_name' => 'admin', 'group_name' => 'Sectors']);
        $role->givePermissionTo('edit_sector');
        Permission::create(['name' => 'delete_sector', 'guard_name' => 'admin', 'group_name' => 'Sectors']);
        $role->givePermissionTo('delete_sector');
        Permission::create(['name' => 'view_sector', 'guard_name' => 'admin', 'group_name' => 'Sectors']);
        $role->givePermissionTo('view_sector');
        Permission::create(['name' => 'add_location', 'guard_name' => 'admin', 'group_name' => 'Locations']);
        $role->givePermissionTo('add_location');
        Permission::create(['name' => 'edit_location', 'guard_name' => 'admin', 'group_name' => 'Locations']);
        $role->givePermissionTo('edit_location');
        Permission::create(['name' => 'delete_location', 'guard_name' => 'admin', 'group_name' => 'Locations']);
        $role->givePermissionTo('delete_location');
        Permission::create(['name' => 'view_location', 'guard_name' => 'admin', 'group_name' => 'Locations']);
        $role->givePermissionTo('view_location');
        Permission::create(['name' => 'add_employee', 'guard_name' => 'admin', 'group_name' => 'Employees']);
        $role->givePermissionTo('add_employee');
        Permission::create(['name' => 'edit_employee', 'guard_name' => 'admin', 'group_name' => 'Employees']);
        $role->givePermissionTo('edit_employee');
        Permission::create(['name' => 'delete_employee', 'guard_name' => 'admin', 'group_name' => 'Employees']);
        $role->givePermissionTo('delete_employee');
        Permission::create(['name' => 'view_employee', 'guard_name' => 'admin', 'group_name' => 'Employees']);
        $role->givePermissionTo('view_employee');
        Permission::create(['name' => 'view_business_card_request', 'guard_name' => 'admin', 'group_name' => 'business_card_requests']);
        $role->givePermissionTo('view_business_card_request');
        Permission::create(['name' => 'accept_business_card_request', 'guard_name' => 'admin', 'group_name' => 'business_card_requests']);
        $role->givePermissionTo('accept_business_card_request');
        Permission::create(['name' => 'reject_business_card_request', 'guard_name' => 'admin', 'group_name' => 'business_card_requests']);
        $role->givePermissionTo('reject_business_card_request');
        Permission::create(['name' => 'view_id_card_request', 'guard_name' => 'admin', 'group_name' => 'id_card_requests']);
        $role->givePermissionTo('view_id_card_request');
        Permission::create(['name' => 'accept_id_card_request', 'guard_name' => 'admin', 'group_name' => 'id_card_requests']);
        $role->givePermissionTo('accept_id_card_request');
        Permission::create(['name' => 'reject_id_card_request', 'guard_name' => 'admin', 'group_name' => 'id_card_requests']);
        $role->givePermissionTo('reject_id_card_request');
        Permission::create(['name' => 'view_activity_log', 'guard_name' => 'admin', 'group_name' => 'activity_logs']);
        $role->givePermissionTo('view_activity_log');


        //\App\Models\User::factory(10)->create();
        \App\Models\Extension::factory(10)->create();
        \App\Models\Sector::factory(10)->create();
        \App\Models\Prefix::factory(10)->create();
        \App\Models\Position::factory(10)->create();

        $admin = \App\Models\Admin::latest()->first();
        $admin->assignRole($role);

    }
}
