|
|
||
|---|---|---|
| app | ||
| bootstrap | ||
| config | ||
| database | ||
| docs | ||
| public | ||
| resources | ||
| routes | ||
| storage | ||
| tests | ||
| .codex | ||
| .editorconfig | ||
| .env.example | ||
| .gitattributes | ||
| .gitignore | ||
| README.md | ||
| artisan | ||
| attendance.json | ||
| composer.json | ||
| composer.lock | ||
| package-lock.json | ||
| package.json | ||
| phpunit.xml | ||
| vite.config.js | ||
README.md
About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- Simple, fast routing engine.
- Powerful dependency injection container.
- Multiple back-ends for session and cache storage.
- Expressive, intuitive database ORM.
- Database agnostic schema migrations.
- Robust background job processing.
- Real-time event broadcasting.
Laravel is accessible, powerful, and provides tools required for large, robust applications.
Learning Laravel
Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
You may also try the Laravel Bootcamp, where you will be guided through building a modern Laravel application from scratch.
If you don't feel like reading, Laracasts can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Partners program.
Premium Partners
Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.
Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.
License
The Laravel framework is open-sourced software licensed under the MIT license.
Sidak Desa QR Code System
Sistem absensi menggunakan QR Code dengan token dinamis yang berubah secara otomatis.
Fitur
- QR Code dengan token yang berubah setiap 60 detik
- Real-time update menggunakan Pusher
- Anti-replay protection dengan nonce
- Auto-refresh ketika token expired
- Force rotation ketika ada scan yang berhasil
Konfigurasi
1. Environment Variables
Tambahkan konfigurasi berikut di file .env:
# Broadcasting (Pusher)
BROADCAST_DRIVER=pusher
PUSHER_APP_KEY=your_pusher_key
PUSHER_APP_SECRET=your_pusher_secret
PUSHER_APP_ID=your_pusher_app_id
PUSHER_APP_CLUSTER=ap1
# Cache (Redis recommended)
CACHE_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
2. Pusher Setup
- Daftar di Pusher
- Buat aplikasi baru
- Copy credentials ke file
.env - Pastikan channel
attendance.session.{sessionId}diizinkan
API Endpoints
QR Code Generation
GET /api/attendance/sessions/{sessionId}/qrcode
QR Code Verification
POST /api/attendance/verify
Content-Type: application/json
{
"token": "A1B2C3D4",
"user_id": 123,
"device_info": "iPhone 12"
}
Force Rotate Token
POST /api/attendance/sessions/{sessionId}/rotate
Halaman QR Code
GET /attendance/sessions/{sessionId}
Cara Kerja
- Token Generation: Server generate token baru setiap 60 detik
- Auto Refresh: Frontend refresh token 2 detik sebelum expired
- Broadcast: Server broadcast token baru ke semua client via Pusher
- Verification: Ketika user scan, token divalidasi dan langsung generate token baru
- Anti-Replay: Setiap token hanya bisa digunakan sekali dengan nonce
Troubleshooting
QR Code tidak berubah
- Cek konfigurasi Pusher di
.env - Cek console browser untuk error
- Cek log Laravel untuk broadcast error
- Pastikan
BROADCAST_DRIVER=pusher
Token tidak ter-generate
- Cek cache driver (Redis/File)
- Cek log Laravel
- Test endpoint
/api/attendance/sessions/{sessionId}/qrcode
Broadcast tidak berfungsi
- Cek koneksi internet
- Cek Pusher dashboard untuk error
- Cek browser console untuk WebSocket error
- Pastikan channel name benar:
attendance.session.{sessionId}
Postman Test Gagal (409 Conflict - Replayed)
Masalah: Token yang digunakan sudah expired atau sudah pernah digunakan sebelumnya.
Solusi:
-
Gunakan token terbaru:
- Buka halaman test:
http://localhost:8000/test-qr - Klik "Get Latest Token" untuk mendapatkan token baru
- Copy token yang muncul di halaman test
- Gunakan token tersebut di Postman
- Buka halaman test:
-
Test dengan endpoint khusus:
# Dapatkan token terbaru GET http://localhost:8000/api/attendance/sessions/1/latest-token # Gunakan token yang didapat untuk verify POST http://localhost:8000/api/attendance/verify { "token": "TOKEN_DARI_LATEST_TOKEN", "user_id": 123, "device_info": "Postman Test" } -
Force rotate token:
POST http://localhost:8000/api/attendance/sessions/1/rotate
Catatan:
- Token QR berubah setiap 60 detik
- Setiap token hanya bisa digunakan sekali (anti-replay protection)
- QR Code akan otomatis generate ulang setelah verifikasi (berhasil atau gagal)
- Gunakan halaman test untuk monitoring token terbaru
Testing
Manual Test QR Rotation
curl -X POST http://localhost:8000/api/attendance/sessions/1/rotate
Test Verification
curl -X POST http://localhost:8000/api/attendance/verify \
-H "Content-Type: application/json" \
-d '{"token":"A1B2C3D4","user_id":123,"device_info":"test"}'
Logs
Sistem akan mencatat log untuk:
- QR Token generation
- QR Token verification
- Broadcast events
- Error handling
Cek log di storage/logs/laravel.log