<?php

use App\Models\Central\Company;
use App\Services\RbacSeeder;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
    public function up(): void
    {
        $seeder = app(RbacSeeder::class);
        $seeder->seedPermissions();

        Company::query()->each(function (Company $company) use ($seeder) {
            $seeder->seedTenantRoles($company->id);
            $seeder->syncUsersToRoles($company->id);
        });
    }

    public function down(): void
    {
        // Permissions/roles stay — dropping them would break access.
    }
};
