<?php

use App\Modules\Customization\CustomFields\Controllers\CustomFieldPageController;
use Illuminate\Support\Facades\Route;

Route::prefix('settings')->name('settings.')->group(function () {
    Route::prefix('custom-fields')->name('custom-fields.')->middleware(['custom_fields.plan'])->group(function () {
        Route::get('/', [CustomFieldPageController::class, 'index'])
            ->middleware('can:custom_fields.view')
            ->name('index');

        Route::get('/create', [CustomFieldPageController::class, 'create'])
            ->middleware('can:custom_fields.create')
            ->name('create');

        Route::post('/', [CustomFieldPageController::class, 'store'])
            ->middleware('can:custom_fields.create')
            ->name('store');

        Route::get('/{custom_field}/edit', [CustomFieldPageController::class, 'edit'])
            ->middleware('can:custom_fields.update,custom_field')
            ->name('edit');

        Route::put('/{custom_field}', [CustomFieldPageController::class, 'update'])
            ->middleware('can:custom_fields.update,custom_field')
            ->name('update');

        Route::post('/{custom_field}/deactivate', [CustomFieldPageController::class, 'deactivate'])
            ->middleware('can:custom_fields.deactivate,custom_field')
            ->name('deactivate');
    });
});
