<?php

namespace Database\Seeders;

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

class MenuPermissionSeeder extends Seeder
{
    public function run(): void
    {
        $permissions = [
            'view dashboard',
            'view ai',
            'view orders',
            'create orders',
            'edit orders',
            'delete orders',
            'print spk',
            'view delivery notes',
            'create delivery notes',
            'edit delivery notes',
            'delete delivery notes',
            'print delivery notes',
            'manage delivery notes',
            'view cashier bills',
            'view cashier payoff',
            'view cashier history',
            'view cashier pricelist',
            'process payments',
            'manage payments',
            'edit payments',
            'delete payments',
            'refund payments',
            'view production queue',
            'view production history',
            'update production',
            'manage production',
            'start production',
            'move production finishing',
            'complete production',
            'request cancellations',
            'approve cancellations',
            'view cancellations',
            'view attendance',
            'view attendance recap',
            'manage attendance settings',
            'manage attendance',
            'view finance',
            'view finance cash',
            'manage deposits',
            'view payment accounts',
            'create payment accounts',
            'edit payment accounts',
            'delete payment accounts',
            'manage payment accounts',
            'view general journal',
            'view profit loss',
            'view balance sheet',
            'view reports',
            'view cash ledger',
            'view receivables report',
            'view sales reports',
            'view revenue reports',
            'view purchase debt reports',
            'view click reports',
            'view transaction logs',
            'view finance reports',
            'view production reports',
            'view expense reports',
            'view products',
            'create products',
            'edit products',
            'delete products',
            'view units',
            'manage units',
            'view suppliers',
            'create suppliers',
            'edit suppliers',
            'delete suppliers',
            'manage suppliers',
            'view stock categories',
            'manage stock categories',
            'view materials',
            'create materials',
            'edit materials',
            'delete materials',
            'manage materials',
            'view machines',
            'manage machines',
            'view stock usage',
            'manage stock usage',
            'view damaged stock',
            'manage damaged stock',
            'view stock',
            'manage stock',
            'view stock incoming',
            'manage stock incoming',
            'view purchases',
            'create purchases',
            'edit purchases',
            'delete purchases',
            'manage purchases',
            'view purchase payments',
            'manage purchase payments',
            'view expenses',
            'create expenses',
            'edit expenses',
            'delete expenses',
            'manage expenses',
            'view expense categories',
            'manage expense categories',
            'view customers',
            'create customers',
            'edit customers',
            'delete customers',
            'manage customers',
            'view vehicles',
            'create vehicles',
            'edit vehicles',
            'delete vehicles',
            'manage vehicles',
            'view tax settings',
            'manage tax settings',
            'view ppn',
            'manage ppn',
            'view users',
            'create users',
            'edit users',
            'delete users',
            'manage users',
            'manage roles',
            'manage permissions',
            'view employees',
            'create employees',
            'edit employees',
            'delete employees',
            'view salaries',
            'create salaries',
            'edit salaries',
            'delete salaries',
            'manage backups',
            'view settings',
            'edit settings',
            'manage settings',
            'access ai',
            'manage ai',
            'ai.sales',
            'ai.index',
        ];

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

        $developer = Role::firstOrCreate([
            'name' => 'developer',
            'guard_name' => 'web',
        ]);

        $developer->syncPermissions(Permission::all());
    }
}
