laravel-appkit / lockable
Requires
- php: ^7.3|^8.0
- illuminate/support: ^6.0|^7.0|^8.0
Requires (Dev)
- laravel/legacy-factories: ^1.1
- orchestra/testbench: ^4.0|^5.0|^6.0
- phpunit/phpunit: ^8.0
- dev-main
- v1.0.0
- dev-dependabot/composer/phpunit/phpunit-9.6.4
- dev-dependabot/composer/symfony/http-kernel-5.4.20
- dev-dependabot/composer/laravel/legacy-factories-1.3.2
- dev-dependabot/composer/orchestra/testbench-6.25.1
- dev-dependabot/composer/guzzlehttp/psr7-1.8.5
- dev-dependabot/composer/laravel/framework-6.20.13
- dev-dependabot/add-v2-config-file
This package is auto-updated.
Last update: 2025-03-28 16:39:40 UTC
README
Allows a user to acquire a lock on a model, which prevents anyone else from being able to edit it.
Installation
You can install the package via composer:
composer require laravel-appkit/lockable
Usage
Add the AppKit\Lockable\Traits\Lockable
trait to the model you want to set locks on
Add a locked_by
integer column to the corresponding table. This can also be done using the lockable
method on the migration.
<?php namespace App\Models; use AppKit\Lockable\Traits\Lockable; use Illuminate\Database\Eloquent\Model; class Article extends Model { use Lockable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'title', 'body' ]; }
Acquiring Locks
To acquire a lock on a model, call the acquireLock
method on it.
$article->acquireLock();
Releasing Locks
To release the existing lock on a model, call the releaseLock
method on it.
$article->releaseLock();
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email appkit-security@coutts.io instead of using the issue tracker.
Please see SECURITY for more details.
Credits
License
The MIT License (MIT). Please see License File for more information.