1. Go to this page and download the library: Download aaronfrancis/reservable 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/ */
aaronfrancis / reservable example snippets
use AaronFrancis\Reservable\Concerns\Reservable;
class Video extends Model
{
use Reservable;
}
// Reserve for 60 seconds (default)
$video->reserve('processing');
// Reserve for a specific duration in seconds
$video->reserve('processing', 300); // 5 minutes
// Reserve until a specific time
$video->reserve('processing', now()->addHour());
// Reserve with CarbonInterval
$video->reserve('processing', CarbonInterval::minutes(5));
$video->reserve('processing', CarbonInterval::hours(2));
if ($video->isReserved('processing')) {
// Model is currently reserved
}
$video->releaseReservation('processing');
// Wait up to 10 seconds (default) for the lock
$video->blockingReserve('processing', duration: 60);
// Wait up to 30 seconds
$video->blockingReserve('processing', duration: 60, wait: 30);
// With CarbonInterval
$video->blockingReserve('processing', CarbonInterval::minutes(5), wait: 30);
$result = $video->reserveWhile('processing', 300, function ($video) {
// Do work while holding the lock...
return $video->transcode();
}); // Lock is automatically released
$video->reserve('processing', 60);
// Later, if you need more time:
$video->extendReservation('processing', 60); // Add 60 more seconds