Download the PHP package hyperlink/laravel-model-locking without Composer
On this page you can find all versions of the php package hyperlink/laravel-model-locking. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hyperlink/laravel-model-locking
More information about hyperlink/laravel-model-locking
Files in hyperlink/laravel-model-locking
Package laravel-model-locking
Short Description Wordpress like locking feature for Laravel-Models.
License MIT
Informations about the package laravel-model-locking
Laravel Model Locking by HYPERLINK GROUP
Installation
You can install the package via composer:
You can publish the config file with:
You can publish the translation files with:
You can publish the vue-components via:
Usage
Setting up your models
Within a model just use the IsLockable
-Trait.
Additionally you have to extend the database-tables for the Model.
simple Model-Locking
If you want just a simple version of the locking, just use the Traits methods within your controller. HEARTBEAT_LOCK_DURATION
should be set to something like 15 minutes (900 seconds).
To make sure no locks are missed you should use the locking:release
Artisan command in your scheduler.
Additionally, you should publish the config and set the lock duration to around 15 minutes.
Model-Locking by heartbeat (Vue)
The more advanced approach is to handle the locks via a heartbeat. This only works for Vue
and axios
.
- Publish the vue-components
-
register the global HeartbeatManager
-
register the Listener-Components
- for index-pages
Handle the wished behavior like showing the current locker by the
lock
event and delete this information on theunlock
-event. -
register the LockRefresher on your Edit-form.
The
lost
-Event shows if the component tries to render if the model is locked by another user than the logged in.
Environment variables
Variable | Default | Description |
---|---|---|
HEARTBEAT_LOCK_DURATION |
70 | The time in seconds a model is locked. |
MIX_HEARTBEAT_REFRESH |
60 | The time in seconds between the heartbeats. Should be a multiple of the MIX_HEARTBEAT_STATUS -interval. |
MIX_HEARTBEAT_STATUS |
30 | The time in seconds between the heartbeats for status-request (index-Listener). |
MIX_HEARTBEAT_ENABLED |
true | Activates or deactivates the heartbeats. |
config
Beside the environment variables, there is a middleware
key to determine the middleware(s) used by the heartbeat-route. Default it's set to api
.