PHP code example of sajtiii / laravel-lockable-attributes

1. Go to this page and download the library: Download sajtiii/laravel-lockable-attributes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sajtiii / laravel-lockable-attributes example snippets


Schema::create('my_models', function (Blueprint $table) {
    ...
    $table->json('locked_attributes');
    ...
});

use Sajtiii\LockableAttributes\Concerns\InteractsWithLockedAttributes;
use Sajtiii\LockableAttributes\Contracts\HasLockedAttributes;

class MyModel extends Model implements HasLockedAttributes
{
    use InteractsWithLockedAttributes;
    
    ...
}

class MyModel extends Model implements HasLockedAttributes
{
    use InteractsWithLockedAttributes;
    
    public function getLockableAttributes(): array
    {
        return [
            'name',
            'title',
            ...
        ];
    }

use Filament\Forms\Components\TextInput;
use Sajtiii\LockableAttributes\Contracts\HasLockedAttributes;
use Sajtiii\LockableAttributes\Filament\Forms\Actions\ToggleAttributeLockAction;

TextInput::make('name')
    ->suffixAction(ToggleAttributeLockAction::make('lock'))
    ->disabled(fn (?HasLockedAttributes $record) => $record && $record->isAttributeLocked($this->getStatePath(false))),