Download the PHP package lowerrocklabs/laravel-lockable without Composer
On this page you can find all versions of the php package lowerrocklabs/laravel-lockable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-lockable
Laravel Lockable provides traits to allow for models to be locked
This model allows for on-demand locking of models. You can integrate this with your permissions methodology of choice, or leave it stand-alone. This package allows you to determine whether a particular instance of a model is Locked or Not. Or it will independently prevent updating of a model instance.
Installation
Requires [PHP 7.3+ or 8.0+] and [Laravel 8.x or 9.x] (https://laravel.com/docs/8.x/releases or https://laravel.com/docs/9.x/releases)
You can install the package via composer:
You can publish and run the migrations with:
You can publish the config file with:
This is the contents of the published config file, which controls the global lock duration, this is customisable on a per-model basis (see below).
Usage
Model Configuration
In the Model(s) that you wish to be lockable, add the IsLockable Trait
and then set the Trait
In Your Component/Controller
Then use the acquireLock function to attempt to acquire a lock on the model, it will return false if there is an existing lock.
You can override the existing lock by calling the releaseLock() function before acquireLock(), if you are using a permissions-based approach, it is suggested that you restrict this to approriate users.
You can tell if a lock exists as follows, this will acquire the lock if one does not exist.
You can send a Broadcast to the user holding the lock with the following
Lock Duration
You can override the default Lock Duration (in seconds) which is taken from the configuration on a per-model basis by setting the following in your Model, for example, the following would limit the duration of a lock to 600 seconds.
Locks will clear when the Duration has expired, and an attempt is made to access the Model, or you can call the commands below, or add them to a schedule (as you see fit).
Commands
To Flush Expired Locks
To Flush All Locks
Events
Two Events will be fired during the Lock process, that can be used to fire Notifications or Logs if desired On Model Locking
and On Model UnLocking
An additional event will be fired when a user requests the release of the lock and On Model UnLocking
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Joe
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-lockable with dependencies
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0
laravel/framework Version ^8.0|^9.19|^10.0|^11.0