<?php

namespace Database\Seeders;

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

class PermissionSeeder extends Seeder
{
    public function run(): void
    {
        $permissions = [
            'Orders' => [
                'orders.view' => 'View orders',
                'orders.create' => 'Create orders',
                'orders.edit' => 'Edit orders',
                'orders.delete' => 'Delete orders',
                'orders.change_stage' => 'Move order stage (cutting/stitching/etc.)',
            ],
            'Customers' => [
                'customers.view' => 'View customers',
                'customers.create' => 'Add customers',
                'customers.edit' => 'Edit customers',
                'customers.delete' => 'Delete customers',
            ],
            'Payments' => [
                'payments.view' => 'View payments',
                'payments.collect' => 'Collect / record payments',
            ],
            'Garments' => [
                'garments.view' => 'View garments',
                'garments.manage' => 'Add/edit garments & measurement fields',
            ],
            'Age Types' => [
                'age_types.view' => 'View age types',
                'age_types.manage' => 'Add/edit age types',
            ],
            'Addons' => [
                'addons.view' => 'View addons',
                'addons.manage' => 'Add/edit addons',
            ],
            'Settings' => [
                'settings.view' => 'View price settings',
                'settings.manage' => 'Edit price settings',
            ],
            'Staff' => [
                'staff.view' => 'View staff list',
                'staff.manage' => 'Add/edit staff & assign roles',
            ],
            'Salary' => [
                'salary.view' => 'View salary records',
                'salary.manage' => 'Set pay type & record payments',
            ],
            'Report' => [
                'report.view' => 'View reports',
                'report.export' => 'Export reports (Excel/PDF)',
            ],
        ];

        foreach ($permissions as $module => $items) {
            foreach ($items as $key => $label) {
                Permission::updateOrCreate(
                    ['key' => $key],
                    ['label' => $label, 'module' => $module]
                );
            }
        }
    }
}
