Allows a user to acquire a lock on a model, which prevents anyone else from being able to edit it.
You can install the package via composer:
composer require laravel-appkit/lockable
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'
];
}
To acquire a lock on a model, call the acquireLock
method on it.
$article->acquireLock();
To release the existing lock on a model, call the releaseLock
method on it.
$article->releaseLock();
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see SECURITY for more details.
The MIT License (MIT). Please see License File for more information.