feat(scan): implement scan attempt tracking and validation logic

This commit is contained in:
2026-09-07 16:39:14 -03:00
parent b607c1b673
commit 193e10dc48
10 changed files with 287 additions and 63 deletions

View File

@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('scan_attempts', function (Blueprint $table): void {
$table->id();
$table->string('tenant_code');
$table->foreignId('scanner_user_id')
->nullable()
->constrained('users')
->cascadeOnUpdate()
->nullOnDelete();
$table->foreignId('ticket_id')
->nullable()
->constrained('tickets')
->cascadeOnUpdate()
->nullOnDelete();
$table->text('data')->nullable();
$table->string('result', 32);
$table->timestamp('resolved_at')->nullable();
$table->timestamp('created_at')->useCurrent();
$table->foreign('tenant_code')
->references('codigo')
->on('tenants')
->cascadeOnUpdate()
->restrictOnDelete();
$table->index(['scanner_user_id', 'created_at']);
$table->index(['tenant_code', 'created_at']);
$table->index(['ticket_id', 'created_at']);
$table->index(['tenant_code', 'result', 'created_at']);
});
}
public function down(): void
{
Schema::dropIfExists('scan_attempts');
}
};