<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        DB::table('roles')->where('slug', 'normal')->update([
            'can_manage_employees' => false,
            'can_manage_devices' => false,
            'can_manage_hr' => false,
            'can_manage_payroll' => false,
            'can_view_reports' => false,
            'can_manage_system' => false,
        ]);

        DB::table('roles')->where('slug', 'systemadmin')->update([
            'can_manage_employees' => true,
            'can_manage_devices' => true,
            'can_manage_hr' => true,
            'can_manage_payroll' => false,
            'can_view_reports' => true,
            'can_manage_system' => true,
        ]);

        DB::table('roles')->where('slug', 'superadmin')->update([
            'can_manage_employees' => true,
            'can_manage_devices' => true,
            'can_manage_hr' => true,
            'can_manage_payroll' => true,
            'can_view_reports' => true,
            'can_manage_system' => true,
        ]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        DB::table('roles')->whereIn('slug', ['normal', 'systemadmin', 'superadmin'])->update([
            'can_manage_employees' => false,
            'can_manage_devices' => false,
            'can_manage_hr' => false,
            'can_manage_payroll' => false,
            'can_view_reports' => false,
            'can_manage_system' => false,
        ]);
    }
};
