<?php

namespace Database\Seeders;

use App\Models\Permission;
use Illuminate\Database\Seeder;

class PermissionSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $permissions = [
            // Merchants
            [
                'name' => 'view_merchants',
                'module' => 'merchants',
                'description' => 'Visualizar comerciantes',
            ],
            [
                'name' => 'create_merchants',
                'module' => 'merchants',
                'description' => 'Criar comerciantes',
            ],
            [
                'name' => 'edit_merchants',
                'module' => 'merchants',
                'description' => 'Editar comerciantes',
            ],
            [
                'name' => 'delete_merchants',
                'module' => 'merchants',
                'description' => 'Excluir comerciantes',
            ],

            // Payments
            [
                'name' => 'create_payments',
                'module' => 'payments',
                'description' => 'Criar pagamentos',
            ],
            [
                'name' => 'view_payments',
                'module' => 'payments',
                'description' => 'Visualizar pagamentos',
            ],
            [
                'name' => 'refund_payments',
                'module' => 'payments',
                'description' => 'Reembolsar pagamentos',
            ],

            // Users
            [
                'name' => 'manage_users',
                'module' => 'users',
                'description' => 'Gerenciar usuários',
            ],
            [
                'name' => 'view_users',
                'module' => 'users',
                'description' => 'Visualizar usuários',
            ],

            // Markets
            [
                'name' => 'manage_markets',
                'module' => 'markets',
                'description' => 'Gerenciar mercados',
            ],
            [
                'name' => 'view_markets',
                'module' => 'markets',
                'description' => 'Visualizar mercados',
            ],

            // Reports
            [
                'name' => 'view_reports',
                'module' => 'reports',
                'description' => 'Visualizar relatórios',
            ],
            [
                'name' => 'generate_reports',
                'module' => 'reports',
                'description' => 'Gerar relatórios',
            ],
        ];

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