<?php

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

return new class extends Migration
{
    public function up(): void
    {
        $now = now();

        foreach (['owner', 'admin_cabang', 'manager'] as $role) {
            DB::table('role_permissions')->updateOrInsert(
                ['role' => $role, 'permission' => 'expenses'],
                ['allowed' => true, 'created_at' => $now, 'updated_at' => $now],
            );
        }
    }

    public function down(): void
    {
        DB::table('role_permissions')->where('permission', 'expenses')->delete();
    }
};
