Download the PHP package blendbyte/filament-resource-lock without Composer

On this page you can find all versions of the php package blendbyte/filament-resource-lock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-resource-lock

Resource Lock

Latest Version on Packagist Tests Static Analysis

Filament Resource Lock is a Filament plugin that adds resource locking functionality to your site. When a user begins editing a resource, it is automatically locked to prevent other users from editing it at the same time. The resource will be automatically unlocked after a set period of time, or when the user saves or discards their changes.

Note: This package is a fork of kenepa/resource-lock, updated for Filament v5 compatibility. If you are currently using kenepa/resource-lock, see the migration guide below.

Installation

Then run the installation command to publish and run the migration:

Register the plugin with a panel:

Quick Start

1. Add locks to your model

Add the HasLocks trait to the model you want to lock:

2. Add locks to your EditRecord page

Add the UsesResourceLock trait to your EditRecord page:

That's it — editing a resource now locks it automatically.

Usage

Simple modal resources

For simple modal resources, use UsesSimpleResourceLock instead:

Relation manager locking

To lock related records when editing them via a relation manager, add UsesRelationManagerResourceLock to your relation manager class. The related model also needs the HasLocks trait.

When a user opens the edit modal for a related record, it is locked for the duration of the edit session and released when the modal is closed.

Table lock indicators

Add ResourceLockColumn to any resource table to display a visual lock status indicator for each row. It shows a lock icon in primary (blue) when the record is locked by the current user, or danger (red) when locked by another user. Unlocked records show no icon.

Add the WithResourceLockIndicator trait to the corresponding ListRecords page to eager-load the lock relationship and avoid N+1 queries:

When shouldDisplayResourceLockOwner() is enabled on the plugin, the column tooltip will display the lock owner's name (e.g. "Locked by John Doe"). Otherwise it falls back to "Locked by another user".

Polling (SPA mode)

To support SPA mode, enable polling-based presence detection in the plugin:

Tip: Make sure the lock timeout is not lower than the polling interval — otherwise the lock may expire before the next heartbeat is sent.

Additional polling options:

Resource Lock Manager

The package includes a UI to view and manage all active and expired locks, and to unlock resources individually or in bulk.

Events

The package dispatches Laravel events for every lock lifecycle transition. Events are enabled by default and can be consumed by any standard Laravel listener.

Event Payload
ResourceLocked $lockable, $userId
ResourceUnlocked $lockable, $userId
ResourceLockExpired $lockable, $originalUserId
ResourceLockForceUnlocked $lockable, $originalUserId, $actorUserId

Register a listener in your AppServiceProvider or EventServiceProvider:

To disable all event dispatching:

Or via the plugin fluent API:

Audit Trail

The audit trail records every lock lifecycle event to a resource_lock_audit table, giving you a permanent, queryable history of who locked what and when.

Audit logging is opt-in (audit.enabled defaults to false) and requires events.enabled to be true, as it is powered by the event system.

Enabling the audit trail

Publish and run the migration (if not already done via filament-resource-lock:install):

Enable audit logging in your config:

Or via the plugin fluent API:

Audit resource

When audit.enabled is true, a read-only Lock Audit Log resource becomes visible in your Filament panel. It displays all recorded events with a colour-coded action badge, filterable by action type and date range.

The audit resource navigation can be customised independently of the lock manager:

To restrict who can view the Audit Log resource, enable limited access and specify a gate:

Or via config:

When limited_access is true, only users for whom Gate::allows($gate) returns true can view the resource. This works with any standard Laravel gate or Spatie permissions ('gate' => 'view audit log').

To enable audit logging but hide the built-in resource (e.g. you have a custom UI):

Configuration

Read-only mode

By default, when a user opens a resource that is locked by someone else, a blocking modal is shown. Enable read-only mode to show a warning banner instead, while keeping the page accessible for viewing:

When read-only mode is active:

Or configure it via the config file:

Per-model lock timeout

Declare a $lockTimeout property (in seconds) on any model using HasLocks to override the global default for that model:

The global default (lock_timeout in config, or ->lockTimeout() on the plugin) is used for all models that do not declare their own property.

Access control

Restrict access to the Unlock button or resource manager using a gate or Spatie permission:

Custom models

Custom lock owner display

Create a custom action class extending GetResourceLockOwnerAction:

Register it in the plugin:

Overriding the return URL

Override resourceLockReturnUrl() to change where the Return button redirects:

Scheduled auto-clear

The package automatically registers a scheduled task that runs filament-resource-lock:clear-expired --force every hour. This is enabled by default (opt-out).

To disable it and manage the schedule yourself:

Then register it manually with whatever frequency suits your app:

Note: Laravel's scheduler requires a cron entry on your server: * * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1

Publishing Assets

Migrating from kenepa/resource-lock

This fork introduces the following breaking changes:

  1. Composer package — replace kenepa/resource-lock with blendbyte/filament-resource-lock
  2. PHP namespace — find and replace Kenepa\ResourceLock with Blendbyte\FilamentResourceLock across your application
  3. Config file — the config was renamed from resource-lock.php to filament-resource-lock.php. Re-publish if you have a customised config:

  4. Artisan commands — command signatures changed from resource-lock:* to filament-resource-lock:* (e.g. filament-resource-lock:install)
  5. Filament version — this package requires Filament v5. The original kenepa/resource-lock targets Filament v3/v4.

Quick steps:

Then update all use Kenepa\ResourceLock\... import statements to use Blendbyte\FilamentResourceLock\....

Contributing

Please see GitHub releases for changelog information.

Maintained by Blendbyte


Blendbyte

Blendbyte builds cloud infrastructure, web apps, and developer tools.
We've been shipping software to production for 20+ years.

This package runs in our own stack, which is why we keep it maintained.
Issues and PRs get read. Good ones get merged.


blendbyte.com · [email protected]


All versions of filament-resource-lock with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
filament/filament Version ^5.0
spatie/laravel-package-tools Version ^1.16.0
illuminate/contracts Version ^11.28|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package blendbyte/filament-resource-lock contains the following files

Loading the files please wait ...