PHPackages                             kenepa/resource-lock - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kenepa/resource-lock

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kenepa/resource-lock
====================

Filament Resource Lock is a Filament plugin that adds resource locking functionality to your site.

4.0.0(9mo ago)9899.1k↓16.2%28[10 issues](https://github.com/kenepa/resource-lock/issues)[4 PRs](https://github.com/kenepa/resource-lock/pulls)2MITPHPPHP ^8.2CI passing

Since Apr 6Pushed 9mo ago7 watchersCompare

[ Source](https://github.com/kenepa/resource-lock)[ Packagist](https://packagist.org/packages/kenepa/resource-lock)[ Docs](https://github.com/kenepa/resource-lock)[ RSS](/packages/kenepa-resource-lock/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (30)Used By (2)

Resource Lock
=============

[](#resource-lock)

[![filament-resource-lock-art](https://raw.githubusercontent.com/kenepa/Kenepa/main/art/ResourceLock/filament-resource-log-banner.png)](https://github.com/kenepa/resource-lock)[![Latest Version on Packagist](https://camo.githubusercontent.com/ffb675538368ce1a62f9541ec38f1bcc48eeb1f1dcd7f95d34a207135ecb737f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b656e6570612f7265736f757263652d6c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kenepa/resource-lock)[![Total Downloads](https://camo.githubusercontent.com/122aea8661e4836f98bfd948fda620fafe074de94c00350db9252c460c10c1d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b656e6570612f7265736f757263652d6c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kenepa/resource-lock)

Filament Resource Lock is a Filament plugin that adds resource locking functionality to your site. When a user begins editing a resource, Filament Resource Lock automatically locks the resource 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.

[![filament-resource-lock-art](https://raw.githubusercontent.com/kenepa/Kenepa/main/art/ResourceLock/filament-resource-lock-demo.gif)](https://raw.githubusercontent.com/kenepa/Kenepa/main/art/ResourceLock/filament-resource-lock-demo.gif)

Installation
------------

[](#installation)

Plugin VersionFilament VersionPHP Version1.x2.x8.0+2.x3.x8.1+3.x3.x8.1+4.x4.x8.2+You can install the package via composer:

```
composer require kenepa/resource-lock
```

Then run the installation command to publish and run migration(s)

```
php artisan resource-lock:install
```

Register plugin with a panel

```
use Kenepa\ResourceLock\ResourceLockPlugin;
use Filament\Panel;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugin(ResourceLockPlugin::make());
}
```

Upgrade guides
==============

[](#upgrade-guides)

Upgrade to 2.x
--------------

[](#upgrade-to-2x)

> Notice - Upgrading to Version 2.1.x :
> In case you have published the config, make sure to update the following in your config:
>
> ```
>    'resource' => [
>        'class' => \Kenepa\ResourceLock\Resources\LockResource::class,
>    ],
> ```

Upgrade from 2.x to 3.x
-----------------------

[](#upgrade-from-2x-to-3x)

### Breaking Changes

[](#breaking-changes)

- **Plugin-based Customization**: Icons, labels, model classes, and access gates now configured via the plugin.
- **Timeout unit changed**: Now uses seconds instead of minutes

Usage
-----

[](#usage)

The Filament Resource Lock package enables you to lock a resource and prevent other users from editing it at the same time. Currently, this package only locks the [EditRecord](https://filamentphp.com/docs/2.x/admin/resources/editing-records) page and the edit modal when editing a [simple modal resource.](https://filamentphp.com/docs/2.x/admin/resources/getting-started#simple-modal-resources)Follow the steps below to add locks to your resources.

### Add Locks to your model

[](#add-locks-to-your-model)

The first step is to add the HasLocks trait to the model of your resource. The HasLocks trait enables the locking functionality on your model.

```
// Post.php

use Kenepa\ResourceLock\Models\Concerns\HasLocks;

class Post extends Model
{
    use HasFactory;
    use HasLocks;

    protected $table = 'posts';

    protected $guarded = [];
}
```

### Add Locks to your EditRecord Page

[](#add-locks-to-your-editrecord-page)

The second step is to add the UsesResourceLock trait to your EditRecord page. The UsesResourceLock trait enables the locking function on your edit page.

```
// EditPost.php

use Kenepa\ResourceLock\Resources\Pages\Concerns\UsesResourceLock;

class EditPost extends EditRecord
{
    use UsesResourceLock;

    protected static string $resource = PostResource::class;
}
```

#### Simple modal Resource

[](#simple-modal-resource)

If your resource is a [simple modal](https://filamentphp.com/docs/2.x/admin/resources/getting-started#simple-modal-resources) resource, you'll need to use the UsesSimpleResourceLock trait instead.

```
// ManagePosts.php

use Kenepa\ResourceLock\Resources\Pages\Concerns\UsesSimpleResourceLock;

class ManagePosts extends ManageRecords
{
    use UsesSimpleResourceLock;

    protected static string $resource = PostResource::class;

}
```

And that's it! Your resource is now able to be locked. Refer to the documentation below for more information on how to configure the locking functionality.

Use polling to detect presence (SPA mode)
-----------------------------------------

[](#use-polling-to-detect-presence-spa-mode)

To make the resource locking feature possible for SPA we polling based detection to check if a user is still editing the resource. This is disabled by default but you can enable it in the config:

```
use Kenepa\ResourceLock\ResourceLockPlugin;
use Filament\Panel;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugin(ResourceLockPlugin::make()
        ->usesPollingToDetectPresence()
        ->presencePollingInterval(10)
        ->lockTimeout(15)
        );
}
```

> **Tip:**
> Make sure the lock timeout is **not** set to a value lower than the presence‑polling interval. If it is, the lock may time out before a new heartbeat is sent, allowing another user to acquire the lock while the current user is still editing the page.

### Polling Configuration

[](#polling-configuration)

When using polling to detect presence, you can configure additional options (by default Livewire will reduce the number of polling requests by 95% until the user revisits the tab.

):

- **`pollingKeepAlive()`**: Keeps the polling connection alive even when the user has the tab in the background.
- **`pollingVisible()`**: Only polls when the browser tab is visible to the user. This helps reduce server load by pausing polling when users switch to other tabs.

Resource Lock manager
---------------------

[](#resource-lock-manager)

[![filament-resource-lock-art](https://raw.githubusercontent.com/kenepa/Kenepa/main/art/ResourceLock/filament-resource-lock-manager.png)](https://raw.githubusercontent.com/kenepa/Kenepa/main/art/ResourceLock/filament-resource-lock-manager.png)

The package also provides a simple way to manage and view all your active and expired locks within your app. And it also provides a way to quickly unlock all resources or specific locks.

Configuration
-------------

[](#configuration)

### Access

[](#access)

[![filament-resource-lock-art](https://raw.githubusercontent.com/kenepa/Kenepa/main/art/ResourceLock/filament-locked.png)](https://raw.githubusercontent.com/kenepa/Kenepa/main/art/ResourceLock/filament-locked.png)

You can restrict the access to the **Unlock** button or to the resource manager by adjusting the access variable. Enabling the "limited" key and setting it to true allows you to specify either a Laravel Gate class or a permission name from the [Spatie Permissions package](https://github.com/spatie/laravel-permission).

```
use Kenepa\ResourceLock\ResourceLockPlugin;
use Filament\Panel;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->limitedAccessToResourceLockManager()
        ->gate('unlock')
}
```

Example

```
// Example using gates
// More info about gates: https://laravel.com/docs/authorization#writing-gates
Gate::define('unlock', function (User $user, Post $post) {
  return $user->email === 'admin@mail.com';
});

// Example using spatie permission package
Permission::create(['name' => 'unlock']);
```

### Using custom models

[](#using-custom-models)

Sometimes, you may have a customized implementation for the User model in your application, or you may want to use a custom class for the ResourceLock functionality. In such cases, you can update the configuration file to specify the new class you want to use. This will ensure that the ResourceLock functionality works as expected with the new implementation.

```
use Kenepa\ResourceLock\ResourceLockPlugin;
use Filament\Panel;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->userModel(\App\Models\CustomUser::class)
        ->resourceLockModel(\App\Models\CustomResourceLock::class);
}
```

### Displaying the user who has locked the resource

[](#displaying-the-user-who-has-locked-the-resource)

This package uses actions which allows you to implement your own custom logic. An action class is nothing more than a simple class with a method that executes some logic. [Learn more about actions](https://freek.dev/2442-strategies-for-making-laravel-packages-customizable)

To create a custom action, first create a file within your project and name it `CustomGetResourceLockOwnerAction.php`, for example. In this file, create a new class that extends the `GetResourceLockOwnerAction` class and override the execute method to return the desired identifier. For example:

```
// CustomGetResourceLockOwnerAction.php

namespace App\Actions;

use Kenepa\ResourceLock\Actions\GetResourceLockOwnerAction;

class CustomResourceLockOwnerAction extends GetResourceLockOwnerAction
{
    public function execute($userModel): string|null
    {
        return $userModel->email;
    }
}
```

Next, register your custom action within the your plugin configuration:

```
use Kenepa\ResourceLock\ResourceLockPlugin;
use Filament\Panel;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugin(
            ResourceLockPlugin::make()
                ->resourceLockOwnerAction(\Kenepa\ResourceLock\Actions\CustomGetResourceLockOwnerAction::class)
        );
}
```

### Overriding default functionality

[](#overriding-default-functionality)

If you need some custom functionality beyond what the traits provide, you can override the functions that they use. For example, if you want to change the URL that the "Return" button redirects to, you can override the resourceLockReturnUrl() function. By default, this button takes you to the index page of the resource, but you can change it to whatever URL you want by adding your custom implementation in the resourceLockReturnUrl() function.

For instance, if you want the "Return" button to redirect to , you can override the function as follows:

```
     public function resourceLockReturnUrl(): string
    {
        return 'https://laracasts.com';
    }
```

Now the return url will redirect to laracasts.com

This will change the behavior of the "Return" button to redirect to the provided URL.

Publishing migrations, configuration and view
---------------------------------------------

[](#publishing-migrations-configuration-and-view)

```
php artisan vendor:publish --tag="resource-lock-migrations"
php artisan migrate
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="resource-lock-migrations"
php artisan migrate
```

Optionally, you can publish the views using

> Note: Publishing Blade views can introduce breaking changes into your app. If you're interested in how to stay safe, [see this article by Dan Harrin](https://filamentphp.com/blog/publishing-views-in-laravel).

```
php artisan vendor:publish --tag="resource-lock-views"
```

Coming soon
-----------

[](#coming-soon)

- Locked status indicator for table rows
- Polling
- Optimistic Locking

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance56

Moderate activity, may be stable

Popularity49

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 78.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~30 days

Recently: every ~13 days

Total

29

Last Release

277d ago

Major Versions

1.1.1 → 2.0.02023-08-08

1.1.2 → 2.0.22023-08-31

2.1.3 → 3.0.02025-06-24

2.x-dev → 3.0.12025-07-15

3.x-dev → 4.0.02025-08-14

PHP version history (3 changes)1.0.0PHP ^8.0

2.0.0PHP ^8.1

4.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/401929a03ca00ed1785ae3f46778422e6b47366ff5eec6f4e8f4a9adc6dfa9a7?d=identicon)[jefta](/maintainers/jefta)

---

Top Contributors

[![Jehizkia](https://avatars.githubusercontent.com/u/8775667?v=4)](https://github.com/Jehizkia "Jehizkia (84 commits)")[![howdu](https://avatars.githubusercontent.com/u/533658?v=4)](https://github.com/howdu "howdu (4 commits)")[![atmonshi](https://avatars.githubusercontent.com/u/1952412?v=4)](https://github.com/atmonshi "atmonshi (3 commits)")[![CodeWithDennis](https://avatars.githubusercontent.com/u/23448484?v=4)](https://github.com/CodeWithDennis "CodeWithDennis (3 commits)")[![DariusIII](https://avatars.githubusercontent.com/u/3399658?v=4)](https://github.com/DariusIII "DariusIII (1 commits)")[![gerardg](https://avatars.githubusercontent.com/u/20286?v=4)](https://github.com/gerardg "gerardg (1 commits)")[![hamrak](https://avatars.githubusercontent.com/u/5807028?v=4)](https://github.com/hamrak "hamrak (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![mohamedsabil83](https://avatars.githubusercontent.com/u/10126040?v=4)](https://github.com/mohamedsabil83 "mohamedsabil83 (1 commits)")[![MunaALB](https://avatars.githubusercontent.com/u/45367528?v=4)](https://github.com/MunaALB "MunaALB (1 commits)")[![OlyaK95](https://avatars.githubusercontent.com/u/129214474?v=4)](https://github.com/OlyaK95 "OlyaK95 (1 commits)")[![stereshko](https://avatars.githubusercontent.com/u/14062824?v=4)](https://github.com/stereshko "stereshko (1 commits)")[![adriaardila](https://avatars.githubusercontent.com/u/2029010?v=4)](https://github.com/adriaardila "adriaardila (1 commits)")[![teloconfesso](https://avatars.githubusercontent.com/u/63561771?v=4)](https://github.com/teloconfesso "teloconfesso (1 commits)")[![balismatz](https://avatars.githubusercontent.com/u/69709689?v=4)](https://github.com/balismatz "balismatz (1 commits)")[![bashgeek](https://avatars.githubusercontent.com/u/4669888?v=4)](https://github.com/bashgeek "bashgeek (1 commits)")[![danielbehrendt](https://avatars.githubusercontent.com/u/283437?v=4)](https://github.com/danielbehrendt "danielbehrendt (1 commits)")

---

Tags

laravelKeneparesource-lock

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/kenepa-resource-lock/health.svg)

```
[![Health](https://phpackages.com/badges/kenepa-resource-lock/health.svg)](https://phpackages.com/packages/kenepa-resource-lock)
```

###  Alternatives

[guava/calendar

Adds support for vkurko/calendar to Filament PHP.

298241.0k3](/packages/guava-calendar)[pboivin/filament-peek

Full-screen page preview modal for Filament

253319.6k12](/packages/pboivin-filament-peek)[dotswan/filament-map-picker

Easily pick and retrieve geo-coordinates using a map-based interface in your Filament applications.

124139.3k2](/packages/dotswan-filament-map-picker)[creagia/filament-code-field

A Filamentphp input field to edit or view code data.

58289.3k3](/packages/creagia-filament-code-field)[swisnl/filament-backgrounds

Beautiful backgrounds for Filament auth pages

54149.2k6](/packages/swisnl-filament-backgrounds)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
