PHP code example of sfolador / laravel-locked

1. Go to this page and download the library: Download sfolador/laravel-locked 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/ */

    

sfolador / laravel-locked example snippets


return [
   'locking_column' => 'locked_at',
   
    'default_namespace' => 'App\Models',

    'unlock_allowed' => true,
    'can_be_unlocked' => [
    ],
    
    'prevent_modifications_on_locked_objects' => false,
];

use Sfolador\Locked\Traits\HasLocks;

class User extends Model
{
    use HasLocks;
}

$user = User::find(1);
$user->lock();

//...

if ($user->isNotLocked()) {
   UserManager::update($user);
}
bash
php artisan vendor:publish --tag="locked-config"
bash
php artisan lock-add {classname} {--namespace=}
bash
php artisan lock-add User
bash
php artisan migrate
bash
php artisan lock-add User --namespace=App\Models\SomeFolder