承接 balismatz/filament-prevent-outdated-record-update 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

balismatz/filament-prevent-outdated-record-update

最新稳定版本:v4.0.0

Composer 安装命令:

composer require balismatz/filament-prevent-outdated-record-update

包简介

Filament package to prevent the update of outdated records.

README 文档

README

A Filament plugin that prevents users from updating outdated records.

When an outdated record is detected, the update process is stopped and a notification is shown to the user.

A record is considered outdated when it has been modified more recently by another user or when its changes have already been saved. This check is performed based on the updated_at attribute.

Requirements

  • PHP 8.2 or higher
  • Laravel 11.28 or higher
  • Filament 4.0 or higher

Installation

Require the package using Composer:

composer require balismatz/filament-prevent-outdated-record-update

Translate the notification

Currently, the notification text is available in English (en) and Greek (el).

If you want to add your own translations or customize the existing ones, publish the language files:

php artisan vendor:publish --provider="BalisMatz\FilamentPreventOutdatedRecordUpdate\FilamentPreventOutdatedRecordUpdateServiceProvider"

Pull requests for additional language translations are welcome.

Usage

Edit action

To prevent outdated record updates on edit action, call the preventOutdatedRecordUpdate() method.

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

The package uses the beforeFormValidated() action hook. If you are also using this hook, you must call it before the preventOutdatedRecordUpdate() method.

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

Edit record (page)

To prevent outdated record updates on the edit record (page), use the PreventsOutdatedRecordUpdate trait.

<?php

namespace App\Filament\Resources\Posts\Pages;

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

class EditPost extends EditRecord
{
    use PreventsOutdatedRecordUpdate;

    // ...
}

The package uses the beforeSave() hook. If you are also using this hook, you can use the PreventsOutdatedRecordUpdate trait, as shown in the following example:

<?php

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();

        // ...
    }

    // ...
}

License

Filament Prevent Outdated Record Update is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 106
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-01