PHP code example of aihimel / laravel-waiting-request
1. Go to this page and download the library: Download aihimel/laravel-waiting-request 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/ */
aihimel / laravel-waiting-request example snippets
use Aihimel\LaravelWaitingRequest\Facades\LWRequest;
LWRequest::addBlocker(User::class, $user->id);
// Optionally override the lifetime (in seconds) per call.
// Non-positive values fall back to the `max_blocking_time` config default.
LWRequest::addBlocker(User::class, $user->id, 30);
use Aihimel\LaravelWaitingRequest\Facades\LWRequest;
// This will wait until the blocker is removed or the timeout is reached
$resolved = LWRequest::whenResolved(User::class, $user->id);
if ($resolved) {
// Process the request
} else {
// Handle timeout
}
use Aihimel\LaravelWaitingRequest\Facades\LWRequest;
LWRequest::resolveBlocker(User::class, $user->id);
if (LWRequest::isBlocked(User::class, $user->id)) {
// Resource is blocked
}