<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;

class PermissionSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run()
    {
        /*
        $permissions = [
            // Permissions for Projects
            'create projects',
            'edit projects',
            'delete projects',
            'view projects',

            // Permissions for Documents
            'create projects',
            'edit projects',
            'delete projects',
            'view projects',
            'approve documents',
            
            'manage users',
            
            // Permissions for roles
            'view roles',
            'create roles',
            'edit roles',
            'delete roles',
            
            // Permissions for permissions
            'view permissions',
            'create permissions',
            'edit permissions',
            'delete permissions',
            'assign permissions',
            'revoke permissions',
        ];

        foreach ($permissions as $permission) {
            Permission::firstOrCreate([
                'name' => $permission,
                'guard_name' => 'web'
            ]);
        }*/

        $permissions = [
            'user' => ['view', 'create', 'edit', 'delete'],
            'document' => ['view', 'upload', 'edit', 'delete', 'approve'],
            'project' => ['view', 'create', 'edit', 'delete'],
            'comment' => ['create', 'edit', 'delete'],
            'folder' => ['view', 'create', 'edit', 'delete'],
            'role' => ['view', 'create', 'edit', 'delete'],
            'permission' => ['view', 'create', 'edit', 'delete'],
        ];
        
        foreach ($permissions as $type => $actions) {
            foreach ($actions as $action) {
                Permission::create(['name' => "{$type}.{$action}"]);
            }
        }
    }
}
