<?php

declare(strict_types=1);

namespace App\Support\Filament\ContentCrud\Concerns;

/**
 * Reusable behavior for Filament EditRecord pages of "content-type" data.
 *
 * Ensures:
 * - section is locked
 * - slug cannot be changed after creation
 */
trait EditsContentRecord
{
    abstract protected function getContentSection(): string;

    protected function mutateFormDataBeforeSave(array $data): array
    {
        $data['section'] = $this->getContentSection();

        unset($data['slug']);

        return $data;
    }
}
