PHP code example of balismatz / filament-prevent-outdated-record-update

1. Go to this page and download the library: Download balismatz/filament-prevent-outdated-record-update 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/ */

    

balismatz / filament-prevent-outdated-record-update example snippets


EditAction::make()
    ->label('Edit record')
    ->preventOutdatedRecordUpdate()

EditAction::make()
    ->label('Edit record')
    ->beforeFormValidated(function () {
        // ...
    })
    ->preventOutdatedRecordUpdate()

EditAction::make()
    ->label('Edit record')
    ->allowOutdatedRecordUpdate()

EditAction::make()
    ->label('Edit record')
    ->allowOutdatedRecordUpdate()
    ->beforeFormValidated(function () {
        // ...
    })

EditAction::make()
    ->label('Edit record')
    ->preventOutdatedRecordUpdate(pivot: true)



namespace App\Filament\Resources\Posts\Pages;

use BalisMatz\FilamentPreventOutdatedRecordUpdate\Concerns\PreventsOutdatedRecordUpdate;
use Filament\Resources\Pages\EditRecord;

class EditPost extends EditRecord
{
    use PreventsOutdatedRecordUpdate;

    // ...
}



namespace App\Filament\Resources\Posts\Pages;

use BalisMatz\FilamentPreventOutdatedRecordUpdate\Concerns\PreventsOutdatedRecordUpdate;
use Filament\Resources\Pages\EditRecord;

class EditPost extends EditRecord
{
    use PreventsOutdatedRecordUpdate {
        beforeSave as preventsOutdatedRecordUpdateBeforeSave;
    }

    // ...

    protected function beforeSave(): void
    {
        // ...

        $this->preventsOutdatedRecordUpdateBeforeSave();

        // ...
    }

    // ...
}
shell
php artisan vendor:publish --provider="BalisMatz\FilamentPreventOutdatedRecordUpdate\FilamentPreventOutdatedRecordUpdateServiceProvider"