PHP code example of risqid / laravel-attendance-engine
1. Go to this page and download the library: Download risqid/laravel-attendance-engine 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/ */
risqid / laravel-attendance-engine example snippets
use Risqid\AttendanceEngine\Services\AttendanceSessionService;
$sessionService = app(AttendanceSessionService::class);
$session = $sessionService->createFromContext([
'name' => 'Rapat Koordinasi',
'starts_at' => now(),
'ends_at' => now()->addHours(4),
'qr_rotation_seconds' => 15,
'action_windows' => [
'check_in' => [
'from' => now()->toIso8601String(),
'until' => now()->addHour()->toIso8601String(),
],
'check_out' => [
'from' => now()->addHours(3)->toIso8601String(),
'until' => now()->addHours(4)->toIso8601String(),
],
],
]);
use Risqid\AttendanceEngine\Services\AttendanceQrService;
$qrService = app(AttendanceQrService::class);
// Returns QrChallenge with payload (32-char binary Base64URL by default), expiry, and remaining seconds
$challenge = $qrService->issueChallenge($session, 'check_in');
$payload = $challenge->payload;
use Risqid\AttendanceEngine\Services\AttendanceScanService;
use Risqid\AttendanceEngine\Data\ScanRequestData;
$scanService = app(AttendanceScanService::class);
$result = $scanService->recordScan(new ScanRequestData(
payload: $payload,
participantId: auth()->id(),
participantType: get_class(auth()->user()),
ipAddress: request()->ip(),
latitude: request()->input('latitude'),
longitude: request()->input('longitude')
));
if ($result->isSuccess()) {
// Attendance successfully recorded
}
use Risqid\AttendanceEngine\Events\AttendanceRecorded;
Event::listen(AttendanceRecorded::class, function (AttendanceRecorded $event) {
$record = $event->record;
// Execute host-specific side effects (e.g. bundling daily attendance)
});
bash
php artisan vendor:publish --tag=attendance-engine-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=attendance-engine-config