<?php

namespace Database\Seeders;

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

class RoleSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {

        // New Roles
        $roles = [
            'مدير جمعية',
            // 'OPERATION_ADMIN',
            // 'OPERATIONAL_MANGER',
            // 'CLASSIFICATION_ADMIN',
            // 'PLANNING_MANAGER',
            // 'PLANNING_ADMIN',
            // 'FINANCIAL_ADMIN',
            // 'FINANCIAL_MANAGER',
            // 'CEO',
            // 'TECHNICAL_ADMIN',
            // 'TECHNICAL_MANAGER',
        ];

        foreach ($roles as $roleName) {
            $role = Role::firstOrCreate(['name' => $roleName]);
            // $role->givePermissionTo($basicPermissions);
        }

        // Assign specific permissions
        // $rolePermissions = [
        //     'PLANNING_MANAGER' => ['request_order_recommendation', 'provide_order_recommendation'],
        //     'OPERATION_ADMIN' => ['request_technical_financial_proposal'],
        //     'OPERATIONAL_MANGER' => ['approve_technical_financial_proposal', 'approve_project_manager'],
        //     'CLASSIFICATION_ADMIN' => ['handle_classification'],
        //     'CEO' => ['handle_agreement', 'approve_ceo', 'launch_project'],
        // ];

        // foreach ($rolePermissions as $roleName => $permissions) {
        //     $role = Role::where('name', $roleName)->first();
        //     if ($role) {
        //         $role->givePermissionTo($permissions);
        //     }
        // }

        // $allPermissions = Permission::where('guard_name', 'web')->get();
        // $admin->givePermissionTo($allPermissions);
    }
}
