Protected Records
Setup
You may need to add a hard-coded reference to a Crud item with a specific identifier in your code, for example, a link to a page with a specific slug. To try and provide some protection from admin users inadvertently changing the identifiers on the item and breaking the site, you are able to specify some that should not be able to be changed by anyone except superusers once created. This works using Eventy filters on the crud.edit.configAfterSetItem and crud.update.configAfterSetItem.
To add this to one of your Cruds, you should add the ControlsProtectedRecords trait to the relevant Crud Controller, and then update/override the configureHooks() function to include a call to $this->configureProtectedRecords();.
Configuration
The crud config file should have a protected_records array key, the value of which should be an array of the identifiers of records to protect.
For example, in order to prevent non superadmins from editing the slug on Page where the slug is about, you would add 'about' to the protected_records array of the file config/enso/crud/page.php. If this array does not exist, you should add one.
By default, this will disable a slug field in the main section the given model when it meets the critera.
If you wish to use a different identifier, you may return the name of a different field by overriding the getProtectedRecordFieldName function provided by the trait.
If your identifier field is in a different section, you may return the name of a different section by overriding the getProtectedRecordSectionName function provided by the trait.