Skip to content

Latest commit

 

History

History
88 lines (60 loc) · 2.56 KB

README.md

File metadata and controls

88 lines (60 loc) · 2.56 KB

Eloquent Lockable

Latest Version on Packagist Build Status Quality Score Total Downloads Licence

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.