<?php

namespace App\Support;

use App\Enums\PermissionSlug;
use Illuminate\Support\Facades\Route;

final class PermissionApiResource
{
    public static function register(
        string $name,
        string $controller,
        PermissionSlug $view,
        PermissionSlug $create,
        PermissionSlug $update,
        PermissionSlug $destroy,
    ): void {
        Route::apiResource($name, $controller)
            ->middlewareFor(['index', 'show'], PermissionSlug::middleware($view))
            ->middlewareFor('store', PermissionSlug::middleware($create))
            ->middlewareFor('update', PermissionSlug::middleware($update))
            ->middlewareFor('destroy', PermissionSlug::middleware($destroy));
    }
}
