PHP code example of lowerrocklabs / laravel-lockable

1. Go to this page and download the library: Download lowerrocklabs/laravel-lockable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lowerrocklabs / laravel-lockable example snippets


return [
    // Name of the Table containing the locks
    'locks_table' => 'model_locks',
    
     // Name of the Table containing the lock watchers
    'lock_watchers_table' => 'model_lock_watchers',
    
    // Enable retrieval of lock status on retrieving a model
    'get_locked_on_retrieve' => true,
    
    // Prevent updating if a model is locked by another user
    'prevent_updating' => true,

    // Time in Seconds For Lock To Persist
    'duration' => '3600',
];

use LowerRockLabs\Lockable\Traits\IsLockable;

use IsLockable;

acquireLock()

releaseLock()

isLocked()

requestLock()

public $modelLockDuration = "600";
 
php artisan locks:flushexpired
 
php artisan locks:flushall

LowerRockLabs\Lockable\Events\ModelWasLocked;

LowerRockLabs\Lockable\Events\ModelWasUnLocked;

LowerRockLabs\Lockable\Events\ModelUnlockRequested;
bash
php artisan vendor:publish --tag="laravel-lockable-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-lockable-config"