Skip to main content
Version: v1 (Current)

Phase 1: Data Model & Database Schema

Historical design/implementation plan. It is retained as background, not a statement that every proposed feature is available. Use the current component/project guides and the deployed editor before following its recipes.

Overview​

This document defines all database schema changes required for the attendee registration system enhancements, including new tables, column additions, and relationship modifications.

Entity Relationship Diagram​

Project
│
├── AttendeeType (1:many)
│ │
│ ├── AttendeeTypeFieldSection (1:many, pivot)
│ │ │
│ │ └── AttendeeFieldOrder (1:many)
│ │ │
│ │ └──→ AttendeeField
│ │
│ ├── AttendeeTypeQuickAction (1:many) [NEW]
│ │
│ └── AttendeeTypePasswordConfig (1:1) [NEW]
│
├── AttendeeField (1:many)
│ │
│ ├── AttendeeFieldTranslation (1:1, optional) [NEW]
│ │ │
│ │ └──→ AttendeeField (source_field)
│ │
│ └── AttendeeFieldEnum (1:many)
│
├── SuggestedFieldTemplate (1:many) [NEW - Super Admin]
│ │
│ └── SuggestedFieldTemplateItem (1:many) [NEW]
│
├── ProjectForm (1:many)
│ │
│ ├── QuizSettings (1:1, optional) [NEW]
│ │ │
│ │ └──→ Game (optional)
│ │
│ └── RegistrationFormSettings (1:1, optional) [NEW]
│
├── FormResumeSession (1:many) [NEW]
│ │
│ └──→ Attendee (optional, for updates)
│
├── AttendeeAsset (1:many) [NEW]
│ │
│ ├──→ Attendee
│ └──→ AttendeeField
│
└── Attendee (1:many)
│
└── AttendeeAsset (1:many) [NEW]

Legend:
──→ = Foreign key direction (child owns the FK)
─── = Parent-child relationship
[NEW] = New table/model

New Tables​

1. suggested_field_templates​

Global templates for suggested attendee fields, managed in super admin.

Schema::create('suggested_field_templates', function (Blueprint $table) {
$table->id();

// Template identification
$table->string('name'); // e.g., "Conference Attendee"
$table->string('slug')->unique(); // e.g., "conference-attendee"
$table->text('description')->nullable();

// Matching criteria
$table->json('attendee_type_keywords')->nullable(); // ["speaker", "presenter", "panelist"]
$table->boolean('is_default')->default(false); // Default template if no match

// Project plan association (null = available to all)
$table->foreignId('project_plan_id')->nullable()->constrained()->nullOnDelete();

// Status
$table->boolean('is_active')->default(true);
$table->integer('sort_order')->default(0);

$table->timestamps();
$table->softDeletes();

$table->index(['is_active', 'sort_order']);
$table->index('project_plan_id');
});

2. suggested_field_template_items​

Individual field definitions within a template.

Schema::create('suggested_field_template_items', function (Blueprint $table) {
$table->id();
$table->foreignId('suggested_field_template_id')->constrained()->cascadeOnDelete();

// Field definition (mirrors AttendeeField structure)
$table->string('name'); // "First Name"
$table->string('slug'); // "first_name"
$table->string('field_type'); // "text", "email", etc.

// Default settings
$table->boolean('is_required')->default(false);
$table->boolean('is_default_for_all_types')->default(false); // Include in all types
$table->boolean('include_in_quick_add')->default(false);
$table->json('validation_rules')->nullable();
$table->text('validation_rules_description')->nullable();
$table->json('options')->nullable(); // For select/radio fields
$table->json('custom_settings')->nullable();

// Ordering
$table->string('section_name')->nullable(); // Suggested section grouping
$table->integer('sort_order')->default(0);

$table->timestamps();

$table->index(['suggested_field_template_id', 'sort_order']);
$table->unique(['suggested_field_template_id', 'slug']);
});

3. attendee_type_quick_actions​

Configurable quick action buttons for attendee edit pages.

Schema::create('attendee_type_quick_actions', function (Blueprint $table) {
$table->id();
$table->foreignId('attendee_type_id')->constrained()->cascadeOnDelete();

// Action definition
$table->string('label'); // "Send Welcome Email"
$table->string('icon')->nullable(); // "envelope"
$table->string('color')->default('primary'); // "primary", "secondary", "danger"

// Action type and configuration
$table->enum('action_type', [
'route', // Navigate to route
'workflow', // Trigger admin workflow
'modal', // Open modal dialog
'api_call', // Make API call
]);
$table->json('action_config'); // Route params, workflow ID, etc.

// Conditional display
$table->json('display_conditions')->nullable(); // Show based on attendee state
$table->json('permission_flags')->nullable(); // Required permissions

// Status
$table->boolean('is_active')->default(true);
$table->integer('sort_order')->default(0);

$table->timestamps();

$table->index(['attendee_type_id', 'is_active', 'sort_order']);
});

4. attendee_type_password_configs​

Password authentication settings per attendee type.

Schema::create('attendee_type_password_configs', function (Blueprint $table) {
$table->id();
$table->foreignId('attendee_type_id')->constrained()->cascadeOnDelete()->unique();

// Enable/disable password auth
$table->boolean('password_auth_enabled')->default(false);

// Username field selection
$table->string('username_field_slug'); // Field to use as username (email, phone, etc.)

// Password rules
$table->integer('min_length')->default(8);
$table->integer('max_length')->default(128);
$table->boolean('require_uppercase')->default(true);
$table->boolean('require_lowercase')->default(true);
$table->boolean('require_number')->default(true);
$table->boolean('require_special')->default(false);
$table->json('disallowed_passwords')->nullable(); // Common passwords to block

// Security settings
$table->integer('max_attempts')->default(5); // Before lockout
$table->integer('lockout_duration')->default(900); // Seconds
$table->boolean('require_password_change')->default(false);
$table->integer('password_expiry_days')->nullable(); // Null = no expiry

$table->timestamps();
});

5. attendee_field_translations​

AI-powered field translation configuration.

Schema::create('attendee_field_translations', function (Blueprint $table) {
$table->id();
$table->foreignId('attendee_field_id')->constrained()->cascadeOnDelete()->unique();

// Source field
$table->foreignId('source_field_id')->constrained('attendee_fields')->cascadeOnDelete();

// Translation configuration
$table->enum('translation_type', [
'language', // Translate to another language
'format', // Format transformation (e.g., date format)
'ai_transform', // Custom AI transformation
]);

// For language translation
$table->string('source_language')->nullable(); // "auto" or ISO code
$table->string('target_language')->nullable(); // ISO code

// For AI transformation
$table->foreignId('ai_interface_id')->nullable()->constrained()->nullOnDelete();
$table->text('transformation_prompt')->nullable(); // Custom prompt for AI

// Caching
$table->boolean('cache_translations')->default(true);
$table->integer('cache_ttl_hours')->default(24);

$table->timestamps();

$table->index('source_field_id');
});

6. registration_form_settings​

Settings specific to registration form type.

Schema::create('registration_form_settings', function (Blueprint $table) {
$table->id();
$table->foreignId('project_form_id')->constrained()->cascadeOnDelete()->unique();

// Mode
$table->enum('registration_mode', [
'new_only', // Only create new attendees
'update_only', // Only update existing attendees
'both', // Allow both
])->default('new_only');

// Attendee type handling
$table->boolean('allow_type_selection')->default(false);
$table->json('allowed_attendee_type_ids')->nullable(); // Null = all types
$table->foreignId('default_attendee_type_id')->nullable()->constrained('attendee_types')->nullOnDelete();

// Duplicate handling
$table->enum('duplicate_check_field', [
'email',
'phone',
'custom',
])->default('email');
$table->string('custom_duplicate_field_slug')->nullable();
$table->enum('duplicate_behavior', [
'reject', // Reject submission
'update', // Update existing record
'allow', // Allow duplicate
'prompt', // Ask user what to do
])->default('reject');

// Resume capability
$table->boolean('resumable')->default(false);
$table->integer('resume_retention_hours')->default(24);
$table->string('resume_contact_field_slug')->default('email'); // Field for sending resume link

// Group assignment
$table->json('auto_assign_group_ids')->nullable(); // Groups to add on registration

// Confirmation
$table->boolean('send_confirmation_email')->default(true);
$table->foreignId('confirmation_template_id')->nullable(); // Notification template

$table->timestamps();
});

7. form_resume_sessions​

Tracks resumable form sessions.

Schema::create('form_resume_sessions', function (Blueprint $table) {
$table->id();
$table->foreignId('project_form_id')->constrained()->cascadeOnDelete();
$table->foreignId('project_id')->constrained()->cascadeOnDelete();

// Session identification
$table->uuid('session_token')->unique();

// Contact info for resume link
$table->string('contact_value'); // Email or phone
$table->string('contact_type'); // "email" or "phone"

// Saved progress
$table->json('form_data'); // Partial form data
$table->string('last_section_id')->nullable(); // Last completed section
$table->integer('completion_percentage')->default(0);

// For updates to existing attendee
$table->foreignId('attendee_id')->nullable()->constrained()->cascadeOnDelete();

// Status
$table->enum('status', [
'in_progress',
'completed',
'expired',
'abandoned',
])->default('in_progress');

// Tracking
$table->timestamp('last_activity_at');
$table->timestamp('expires_at');
$table->integer('resume_link_sent_count')->default(0);
$table->timestamp('last_resume_link_sent_at')->nullable();

// Device info
$table->string('ip_address')->nullable();
$table->string('user_agent')->nullable();

$table->timestamps();

$table->index(['project_form_id', 'status']);
$table->index(['contact_value', 'contact_type']);
$table->index('expires_at');
});

8. quiz_settings​

Settings specific to quiz form type.

Schema::create('quiz_settings', function (Blueprint $table) {
$table->id();
$table->foreignId('project_form_id')->constrained()->cascadeOnDelete()->unique();

// Game integration (optional)
$table->foreignId('game_id')->nullable()->constrained()->nullOnDelete();
$table->boolean('create_game_session')->default(true); // Create session per quiz attempt

// Randomization
$table->boolean('randomize_questions')->default(false);
$table->boolean('randomize_answers')->default(false);
$table->integer('question_limit')->nullable(); // Limit questions shown (null = all)

// Timing
$table->boolean('timed_quiz')->default(false);
$table->integer('quiz_time_limit')->nullable(); // Seconds for entire quiz
$table->boolean('per_question_timer')->default(false);
$table->integer('default_question_time')->nullable(); // Default seconds per question

// Active section (for live quizzes)
$table->string('active_section_id')->nullable(); // Currently active section
$table->boolean('section_progression_locked')->default(false); // Only allow active section

// Scoring
$table->integer('default_points_correct')->default(10);
$table->integer('default_points_incorrect')->default(0);
$table->boolean('allow_partial_credit')->default(false);

// Attempts
$table->integer('max_attempts')->nullable(); // Null = unlimited
$table->enum('attempt_scoring', [
'highest', // Keep highest score
'latest', // Keep latest score
'average', // Average all attempts
'first', // Keep first attempt only
])->default('highest');

// Display settings
$table->boolean('show_correct_answers')->default(false);
$table->enum('show_answers_when', [
'immediately', // After each question
'after_submit', // After quiz submission
'after_deadline', // After quiz closes
'never',
])->default('after_submit');
$table->boolean('show_score_during_quiz')->default(false);

// Leaderboard
$table->boolean('show_leaderboard')->default(false);
$table->enum('leaderboard_type', [
'cumulative',
'high_score',
])->default('high_score');

$table->timestamps();
});

9. quiz_question_settings​

Per-question settings for quizzes (stored alongside form elements).

Schema::create('quiz_question_settings', function (Blueprint $table) {
$table->id();
$table->foreignId('project_form_id')->constrained()->cascadeOnDelete();
$table->string('element_id'); // FormBuilder element ID

// Question type
$table->enum('question_type', [
'single_choice', // One correct answer
'multiple_choice', // Multiple correct answers
'true_false', // True/False
'text_match', // Exact text match
'numeric_range', // Number within range
])->default('single_choice');

// Correct answer(s)
$table->json('correct_answers'); // Array of correct values
$table->boolean('case_sensitive')->default(false); // For text match

// Scoring
$table->integer('points_correct')->nullable(); // Override default
$table->integer('points_incorrect')->nullable(); // Override default
$table->json('answer_multipliers')->nullable(); // {"option_a": 1.5, "option_b": 1.0}

// Timing override
$table->integer('time_limit')->nullable(); // Override default per-question time

// Feedback
$table->text('feedback_correct')->nullable();
$table->text('feedback_incorrect')->nullable();
$table->json('answer_explanations')->nullable(); // Per-answer explanations

$table->timestamps();

$table->unique(['project_form_id', 'element_id']);
});

10. quiz_attempts​

Tracks individual quiz attempts.

Schema::create('quiz_attempts', function (Blueprint $table) {
$table->id();
$table->foreignId('project_form_id')->constrained()->cascadeOnDelete();
$table->foreignId('attendee_id')->constrained()->cascadeOnDelete();

// Game session link
$table->foreignId('game_session_id')->nullable()->constrained()->nullOnDelete();

// Attempt tracking
$table->integer('attempt_number')->default(1);
$table->enum('status', [
'in_progress',
'completed',
'timed_out',
'abandoned',
])->default('in_progress');

// Scoring
$table->integer('total_questions')->default(0);
$table->integer('questions_answered')->default(0);
$table->integer('correct_answers')->default(0);
$table->integer('incorrect_answers')->default(0);
$table->integer('score')->default(0); // Total points
$table->integer('max_possible_score')->default(0);
$table->decimal('percentage', 5, 2)->default(0);

// Timing
$table->timestamp('started_at');
$table->timestamp('completed_at')->nullable();
$table->integer('time_spent_seconds')->default(0);

// Question order (for randomized quizzes)
$table->json('question_order')->nullable(); // Array of element IDs in order shown

// Metadata
$table->json('metadata')->nullable();

$table->timestamps();

$table->index(['project_form_id', 'attendee_id']);
$table->index(['attendee_id', 'status']);
$table->unique(['project_form_id', 'attendee_id', 'attempt_number']);
});

11. quiz_attempt_answers​

Individual question answers within an attempt.

Schema::create('quiz_attempt_answers', function (Blueprint $table) {
$table->id();
$table->foreignId('quiz_attempt_id')->constrained()->cascadeOnDelete();
$table->string('element_id'); // Question element ID

// Answer
$table->json('answer_value'); // Submitted answer(s)
$table->boolean('is_correct')->default(false);
$table->decimal('partial_credit', 5, 2)->default(0); // 0-1 for partial credit

// Scoring
$table->integer('points_awarded')->default(0);
$table->decimal('multiplier_applied', 5, 2)->default(1.0);

// Timing
$table->integer('time_spent_seconds')->default(0);
$table->timestamp('answered_at');

// Point transaction link (if game integrated)
$table->foreignId('point_transaction_id')->nullable();

$table->timestamps();

$table->index(['quiz_attempt_id', 'element_id']);
$table->unique(['quiz_attempt_id', 'element_id']);
});

12. attendee_assets​

Dedicated table for attendee file uploads with approval workflow.

Schema::create('attendee_assets', function (Blueprint $table) {
$table->id();
$table->foreignId('project_id')->constrained()->cascadeOnDelete();
$table->foreignId('attendee_id')->constrained()->cascadeOnDelete();

// Field association (optional)
$table->foreignId('attendee_field_id')->nullable()->constrained()->nullOnDelete();
$table->string('field_slug')->nullable(); // Denormalized for search

// File information
$table->string('original_filename');
$table->string('stored_filename');
$table->string('file_path');
$table->string('mime_type');
$table->bigInteger('file_size'); // Bytes
$table->string('file_extension');

// Processing
$table->enum('status', [
'pending', // Awaiting processing
'processing', // Being scanned/processed
'approved', // Ready for use
'rejected', // Failed scan or manual rejection
'quarantined', // Malware detected
])->default('pending');

// Security
$table->boolean('is_encrypted')->default(false);
$table->string('encryption_key_id')->nullable(); // GPG key identifier
$table->boolean('malware_scanned')->default(false);
$table->timestamp('scanned_at')->nullable();
$table->string('scan_result')->nullable(); // ClamAV result

// Approval workflow
$table->foreignId('approved_by_user_id')->nullable()->constrained('users')->nullOnDelete();
$table->timestamp('approved_at')->nullable();
$table->foreignId('rejected_by_user_id')->nullable()->constrained('users')->nullOnDelete();
$table->timestamp('rejected_at')->nullable();
$table->text('rejection_reason')->nullable();

// Metadata
$table->json('metadata')->nullable(); // Dimensions, duration, etc.
$table->string('thumbnail_path')->nullable();

$table->timestamps();
$table->softDeletes();

$table->index(['project_id', 'status']);
$table->index(['attendee_id', 'status']);
$table->index(['attendee_field_id']);
$table->index('status');
});

Updated Tables​

attendee_fields​

Add columns for new features:

Schema::table('attendee_fields', function (Blueprint $table) {
// Default field flag
$table->boolean('is_default_for_all_types')->default(false)->after('readonly');

// Quick add inclusion
$table->boolean('include_in_quick_add')->default(false)->after('is_default_for_all_types');

// Validation enhancements
$table->json('validation_config')->nullable()->after('validation_rules');
// Structure: {
// "rules": [...],
// "messages": {...},
// "realtime": true,
// "debounce_ms": 300
// }

// Add index for default fields
$table->index(['project_id', 'is_default_for_all_types']);
});

attendee_types​

Add slug auto-generation and advanced options:

Schema::table('attendee_types', function (Blueprint $table) {
// Auto-generate slug (already has slug, add flag)
$table->boolean('slug_auto_generated')->default(true)->after('slug');

// Default photo
$table->string('default_avatar_path')->nullable()->after('preferred_contact_field_slug');

// Quick actions enable
$table->boolean('quick_actions_enabled')->default(true)->after('default_avatar_path');
});

project_forms​

Add form type enum:

Schema::table('project_forms', function (Blueprint $table) {
// Form type
$table->enum('form_type', [
'standard', // Default form type
'registration', // Attendee registration
'quiz', // Quiz/assessment
'survey', // Survey (future)
'poll', // Poll (future)
])->default('standard')->after('slug');

$table->index('form_type');
});

form_fields (for quiz question markers)​

Add quiz-specific flag:

Schema::table('form_fields', function (Blueprint $table) {
// Mark as quiz question
$table->boolean('is_quiz_question')->default(false)->after('custom_settings');
});

Models​

SuggestedFieldTemplate Model​

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class SuggestedFieldTemplate extends Model
{
use SoftDeletes;

protected $fillable = [
'name',
'slug',
'description',
'attendee_type_keywords',
'is_default',
'project_plan_id',
'is_active',
'sort_order',
];

protected $casts = [
'attendee_type_keywords' => 'array',
'is_default' => 'boolean',
'is_active' => 'boolean',
];

public function projectPlan(): BelongsTo
{
return $this->belongsTo(ProjectPlan::class);
}

public function items(): HasMany
{
return $this->hasMany(SuggestedFieldTemplateItem::class)
->orderBy('sort_order');
}

/**
* Find matching template for attendee type name
*/
public static function findForAttendeeType(
string $attendeeTypeName,
?int $projectPlanId = null
): ?self {
$name = strtolower($attendeeTypeName);

// First, try project plan specific templates
if ($projectPlanId) {
$template = static::where('is_active', true)
->where('project_plan_id', $projectPlanId)
->get()
->first(function ($template) use ($name) {
return collect($template->attendee_type_keywords ?? [])
->contains(fn ($keyword) => str_contains($name, strtolower($keyword)));
});

if ($template) {
return $template;
}
}

// Try global templates (no project plan)
$template = static::where('is_active', true)
->whereNull('project_plan_id')
->get()
->first(function ($template) use ($name) {
return collect($template->attendee_type_keywords ?? [])
->contains(fn ($keyword) => str_contains($name, strtolower($keyword)));
});

if ($template) {
return $template;
}

// Fall back to default template
return static::where('is_active', true)
->where('is_default', true)
->first();
}
}

QuizSettings Model​

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class QuizSettings extends Model
{
protected $fillable = [
'project_form_id',
'game_id',
'create_game_session',
'randomize_questions',
'randomize_answers',
'question_limit',
'timed_quiz',
'quiz_time_limit',
'per_question_timer',
'default_question_time',
'active_section_id',
'section_progression_locked',
'default_points_correct',
'default_points_incorrect',
'allow_partial_credit',
'max_attempts',
'attempt_scoring',
'show_correct_answers',
'show_answers_when',
'show_score_during_quiz',
'show_leaderboard',
'leaderboard_type',
];

protected $casts = [
'create_game_session' => 'boolean',
'randomize_questions' => 'boolean',
'randomize_answers' => 'boolean',
'timed_quiz' => 'boolean',
'per_question_timer' => 'boolean',
'section_progression_locked' => 'boolean',
'allow_partial_credit' => 'boolean',
'show_correct_answers' => 'boolean',
'show_score_during_quiz' => 'boolean',
'show_leaderboard' => 'boolean',
];

public function projectForm(): BelongsTo
{
return $this->belongsTo(ProjectForm::class);
}

public function game(): BelongsTo
{
return $this->belongsTo(Game::class);
}

public function questionSettings(): HasMany
{
return $this->hasMany(QuizQuestionSettings::class, 'project_form_id', 'project_form_id');
}

public function attempts(): HasMany
{
return $this->hasMany(QuizAttempt::class, 'project_form_id', 'project_form_id');
}

/**
* Check if attendee can attempt quiz
*/
public function canAttempt(Attendee $attendee): bool
{
if (!$this->max_attempts) {
return true;
}

$attemptCount = $this->attempts()
->where('attendee_id', $attendee->id)
->whereIn('status', ['completed', 'timed_out'])
->count();

return $attemptCount < $this->max_attempts;
}

/**
* Get attendee's best score based on scoring mode
*/
public function getAttendeeScore(Attendee $attendee): ?int
{
$attempts = $this->attempts()
->where('attendee_id', $attendee->id)
->whereIn('status', ['completed', 'timed_out'])
->get();

if ($attempts->isEmpty()) {
return null;
}

return match ($this->attempt_scoring) {
'highest' => $attempts->max('score'),
'latest' => $attempts->sortByDesc('completed_at')->first()->score,
'average' => (int) round($attempts->avg('score')),
'first' => $attempts->sortBy('attempt_number')->first()->score,
default => $attempts->max('score'),
};
}
}

AttendeeAsset Model​

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class AttendeeAsset extends Model
{
use SoftDeletes;

protected $fillable = [
'project_id',
'attendee_id',
'attendee_field_id',
'field_slug',
'original_filename',
'stored_filename',
'file_path',
'mime_type',
'file_size',
'file_extension',
'status',
'is_encrypted',
'encryption_key_id',
'malware_scanned',
'scanned_at',
'scan_result',
'approved_by_user_id',
'approved_at',
'rejected_by_user_id',
'rejected_at',
'rejection_reason',
'metadata',
'thumbnail_path',
];

protected $casts = [
'is_encrypted' => 'boolean',
'malware_scanned' => 'boolean',
'scanned_at' => 'datetime',
'approved_at' => 'datetime',
'rejected_at' => 'datetime',
'metadata' => 'array',
];

public function project(): BelongsTo
{
return $this->belongsTo(Project::class);
}

public function attendee(): BelongsTo
{
return $this->belongsTo(Attendee::class);
}

public function attendeeField(): BelongsTo
{
return $this->belongsTo(AttendeeField::class);
}

public function approvedBy(): BelongsTo
{
return $this->belongsTo(User::class, 'approved_by_user_id');
}

public function rejectedBy(): BelongsTo
{
return $this->belongsTo(User::class, 'rejected_by_user_id');
}

/**
* Check if asset is safe to use
*/
public function isSafe(): bool
{
return $this->status === 'approved' &&
$this->malware_scanned &&
$this->scan_result === 'clean';
}

/**
* Approve the asset
*/
public function approve(User $user): void
{
$this->update([
'status' => 'approved',
'approved_by_user_id' => $user->id,
'approved_at' => now(),
]);
}

/**
* Reject the asset
*/
public function reject(User $user, string $reason): void
{
$this->update([
'status' => 'rejected',
'rejected_by_user_id' => $user->id,
'rejected_at' => now(),
'rejection_reason' => $reason,
]);
}
}

Indexes & Performance Considerations​

Key Indexes​

  1. Suggested field lookup: suggested_field_templates(is_active, project_plan_id)
  2. Quick add fields: attendee_fields(project_id, include_in_quick_add)
  3. Default fields: attendee_fields(project_id, is_default_for_all_types)
  4. Quiz attempts: quiz_attempts(project_form_id, attendee_id)
  5. Asset approval: attendee_assets(project_id, status)
  6. Form resume: form_resume_sessions(expires_at) for cleanup job

Cache Strategy​

// Suggested templates (global, long TTL)
"suggested_field_templates" => 24 hours
"suggested_field_template_{id}" => 24 hours

// Per-project caches
"project_{id}_attendee_type_{id}_quick_actions" => 1 hour
"project_{id}_default_attendee_fields" => 1 hour

// Quiz caches
"quiz_{id}_question_settings" => 15 minutes
"quiz_{id}_leaderboard" => 30 seconds

Cleanup Jobs​

// Scheduled jobs needed:
// 1. Clean expired form resume sessions (hourly)
// 2. Process pending asset scans (every 5 minutes)
// 3. Clear translation cache for updated fields (on field update)
// 4. Archive old quiz attempts (weekly)

Migration Order​

  1. create_suggested_field_templates_table
  2. create_suggested_field_template_items_table
  3. add_form_type_to_project_forms_table
  4. add_fields_to_attendee_fields_table
  5. add_fields_to_attendee_types_table
  6. create_attendee_type_quick_actions_table
  7. create_attendee_type_password_configs_table
  8. create_attendee_field_translations_table
  9. create_registration_form_settings_table
  10. create_form_resume_sessions_table
  11. create_quiz_settings_table
  12. create_quiz_question_settings_table
  13. create_quiz_attempts_table
  14. create_quiz_attempt_answers_table
  15. create_attendee_assets_table
  16. add_is_quiz_question_to_form_fields_table

Next Steps​