<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Spatie\Permission\Models\Permission;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // Create the view-reports permission
        Permission::create(['name' => 'view-reports', 'guard_name' => 'web']);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Remove the view-reports permission
        $permission = Permission::where('name', 'view-reports')->first();
        if ($permission) {
            $permission->delete();
        }
    }
};
