1. Go to this page and download the library: Download byrcsc/laravel-hold 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/ */
byrcsc / laravel-hold example snippets
use ByRcsc\LaravelHold\Concerns\Holdable;
class Seat extends Model
{
use Holdable;
}
$hold = $seat->acquireHold($user, expiresAt: now()->addMinutes(15));
if ($hold === null) {
// No slot available.
}
$hold->extend(CarbonInterval::minutes(5)); // now expires 20 minutes from acquisition
$hold->release();
class Event extends Model
{
use Holdable;
public function holdCapacity(): int
{
return $this->seat_limit; // or any fixed integer
}
}