PHPackages                             quarks/laravel-locking - 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. [Database &amp; ORM](/categories/database)
4. /
5. quarks/laravel-locking

ActiveLibrary[Database &amp; ORM](/categories/database)

quarks/laravel-locking
======================

Easily implement optimistic Eloquent model locking feature to your Laravel app.

1.0.1(3y ago)37.5k↓33.8%[1 issues](https://github.com/qtsolv/laravel-locking/issues)1MITPHPPHP &gt;=7.2

Since Jun 21Pushed 3y agoCompare

[ Source](https://github.com/qtsolv/laravel-locking)[ Packagist](https://packagist.org/packages/quarks/laravel-locking)[ RSS](/packages/quarks-laravel-locking/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (1)

quarks/laravel-locking
======================

[](#quarkslaravel-locking)

Easily implement optimistic [Eloquent](https://laravel.com/docs/6.x/eloquent) model locking feature to your [Laravel](https://laravel.com/) app.

[![Latest Version](https://camo.githubusercontent.com/1f0f35a002b9edaa655723a166990c672895a3eb963d9fc1f79637663f69b372/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7174736f6c762f6c61726176656c2d6c6f636b696e672e7376673f7374796c653d666c61742d737175617265)](https://github.com/qtsolv/laravel-locking/releases)[![Downloads](https://camo.githubusercontent.com/2b4c15bb89579beefc07b33247fb7842f24982d61fe72dd5c903f0e8706d5d3f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f717561726b732f6c61726176656c2d6c6f636b696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/quarks/laravel-locking)[![PHP Version](https://camo.githubusercontent.com/c5d9a5ee4c0f99c39c60458cdde64b73408c3d6520e8aad027a9e59b69ab0b4c/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e322b2d3838393262652e7376673f7374796c653d666c61742d737175617265)](https://www.php.net/downloads)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

### Installation

[](#installation)

```
composer require quarks/laravel-locking
```

### Usage

[](#usage)

In your migration classes, add the version column to your table as below:

```
/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::table('blog_posts', function (Blueprint $table) {
        // create column for version tracking
        $table->lockVersion();
        // or to use a custom column name e.g., lock_version
        $table->lockVersion('lock_version');
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::table('blog_posts', function (Blueprint $table) {
        $table->dropLockVersion(); // or $table->dropLockVersion('lock_version');
    });
}
```

Then add the `LocksVersion` trait your model classes as follows:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Quarks\Laravel\Locking\LocksVersion;

class BlogPost extends Model
{
    use LocksVersion;

    /**
     * Override the default lock version column name, optional.
     */
    protected static function lockVersionColumnName()
    {
        return 'lock_version';
    }
}
```

In your blade templates, include the current lock version as part of the form using the `lockInput` directive as below:

```

    @lockInput($blogPost)

```

In your controllers, fill the lock version from request using below helper:

```
namespace App\Http\Controllers;

use Quarks\Laravel\Locking\LockedVersionMismatchException;

// ... other imports

class BlogPostController extends Controller
{

    // ... more methods

    public function update(BlogPost $blogPost, BlogPostRequest $request)
    {
        $data = $request->validated();
        $blogPost->fill($data);
        $blogPost->fillLockVersion();

        try {
            $blogPost->save();
        } catch (LockedVersionMismatchException $e) {
            abort(409, 'This model was already modified elsewhere.');
        }
    }
}
```

Your model update can now be simply protected from concurrent updates as shown above.

### License

[](#license)

See [LICENSE](LICENSE) file.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~26 days

Total

2

Last Release

1436d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/74d769ac0703ce0c1ab0b9cbbf9907527abcdbf228b7efabb8e6f98c6f8ccc24?d=identicon)[vpzqtsolv](/maintainers/vpzqtsolv)

---

Top Contributors

[![vaibhavpandeyvpz](https://avatars.githubusercontent.com/u/6647172?v=4)](https://github.com/vaibhavpandeyvpz "vaibhavpandeyvpz (9 commits)")

### Embed Badge

![Health badge](/badges/quarks-laravel-locking/health.svg)

```
[![Health](https://phpackages.com/badges/quarks-laravel-locking/health.svg)](https://phpackages.com/packages/quarks-laravel-locking)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[yemenopensource/filament-excel

This package useful for importing excel files into models.

194.2k](/packages/yemenopensource-filament-excel)

PHPackages © 2026

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