Phase 7: Attendee Asset Management
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 details the implementation of a dedicated attendee asset management system with approval workflow, GPG encryption for sensitive files, and ClamAV malware scanning.
Feature Summary
- Attendee Assets Table: Dedicated searchable table for all attendee uploads
- Approval Workflow: Review and approve/reject uploaded files
- GPG Encryption: Encrypt sensitive attendee files at rest
- Malware Scanning: ClamAV integration for security scanning
- Field Association: Link assets to specific attendee fields
- Dashboard Management: Admin interface for asset review
1. AttendeeAsset Model
Full Model Implementation
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Storage;
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',
];
protected $appends = [
'download_url',
'thumbnail_url',
'status_label',
];
// Status constants
public const STATUS_PENDING = 'pending';
public const STATUS_PROCESSING = 'processing';
public const STATUS_APPROVED = 'approved';
public const STATUS_REJECTED = 'rejected';
public const STATUS_QUARANTINED = 'quarantined';
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');
}
/**
* Get download URL attribute
*/
public function getDownloadUrlAttribute(): ?string
{
if (!$this->isSafe()) {
return null;
}
return route('api.attendee-assets.download', $this->id);
}
/**
* Get thumbnail URL attribute
*/
public function getThumbnailUrlAttribute(): ?string
{
if (!$this->thumbnail_path) {
return null;
}
return Storage::url($this->thumbnail_path);
}
/**
* Get status label attribute
*/
public function getStatusLabelAttribute(): string
{
return match ($this->status) {
self::STATUS_PENDING => 'Pending Review',
self::STATUS_PROCESSING => 'Processing',
self::STATUS_APPROVED => 'Approved',
self::STATUS_REJECTED => 'Rejected',
self::STATUS_QUARANTINED => 'Quarantined',
default => 'Unknown',
};
}
/**
* Check if asset is safe to use/download
*/
public function isSafe(): bool
{
return $this->status === self::STATUS_APPROVED &&
$this->malware_scanned &&
$this->scan_result === 'clean';
}
/**
* Check if asset needs review
*/
public function needsReview(): bool
{
return $this->status === self::STATUS_PENDING &&
$this->malware_scanned &&
$this->scan_result === 'clean';
}
/**
* Approve the asset
*/
public function approve(User $user): void
{
$this->update([
'status' => self::STATUS_APPROVED,
'approved_by_user_id' => $user->id,
'approved_at' => now(),
'rejected_by_user_id' => null,
'rejected_at' => null,
'rejection_reason' => null,
]);
event(new AttendeeAssetApproved($this));
}
/**
* Reject the asset
*/
public function reject(User $user, string $reason): void
{
$this->update([
'status' => self::STATUS_REJECTED,
'rejected_by_user_id' => $user->id,
'rejected_at' => now(),
'rejection_reason' => $reason,
]);
event(new AttendeeAssetRejected($this));
}
/**
* Quarantine the asset (malware detected)
*/
public function quarantine(string $scanResult): void
{
$this->update([
'status' => self::STATUS_QUARANTINED,
'scan_result' => $scanResult,
]);
event(new AttendeeAssetQuarantined($this));
}
/**
* Get file contents (decrypted if necessary)
*/
public function getContents(): string
{
$contents = Storage::get($this->file_path);
if ($this->is_encrypted) {
$contents = app(GpgEncryptionService::class)->decrypt(
$contents,
$this->encryption_key_id
);
}
return $contents;
}
/**
* Scope for searchable assets
*/
public function scopeSearchable($query, ?string $search)
{
if (!$search) {
return $query;
}
return $query->where(function ($q) use ($search) {
$q->where('original_filename', 'like', "%{$search}%")
->orWhereHas('attendee', function ($aq) use ($search) {
$aq->where('first_name', 'like', "%{$search}%")
->orWhere('last_name', 'like', "%{$search}%")
->orWhere('contact_email', 'like', "%{$search}%");
});
});
}
/**
* Scope for status filter
*/
public function scopeStatus($query, string $status)
{
return $query->where('status', $status);
}
/**
* Scope for pending review
*/
public function scopePendingReview($query)
{
return $query->where('status', self::STATUS_PENDING)
->where('malware_scanned', true)
->where('scan_result', 'clean');
}
}
2. Asset Upload Service
<?php
namespace App\Services\Attendee;
use App\Models\AttendeeAsset;
use App\Models\AttendeeField;
use App\Models\Attendee;
use App\Models\Project;
use App\Jobs\ScanAttendeeAsset;
use App\Jobs\GenerateAssetThumbnail;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Storage;
class AttendeeAssetService
{
public function __construct(
protected GpgEncryptionService $encryptionService,
protected MalwareScanService $scanService,
) {}
/**
* Upload and store attendee asset
*/
public function upload(
UploadedFile $file,
Attendee $attendee,
?AttendeeField $field = null,
array $options = []
): AttendeeAsset {
$project = $attendee->project;
// Generate stored filename
$storedFilename = Str::uuid() . '.' . $file->getClientOriginalExtension();
$basePath = "attendee-assets/{$project->id}/{$attendee->id}";
// Determine if encryption is needed
$shouldEncrypt = $options['encrypt'] ?? $this->shouldEncrypt($field, $project);
// Store file
$contents = $file->getContent();
if ($shouldEncrypt) {
$keyId = $this->encryptionService->getProjectKeyId($project);
$contents = $this->encryptionService->encrypt($contents, $keyId);
$storedFilename .= '.gpg';
}
$filePath = "{$basePath}/{$storedFilename}";
Storage::put($filePath, $contents);
// Create asset record
$asset = AttendeeAsset::create([
'project_id' => $project->id,
'attendee_id' => $attendee->id,
'attendee_field_id' => $field?->id,
'field_slug' => $field?->slug,
'original_filename' => $file->getClientOriginalName(),
'stored_filename' => $storedFilename,
'file_path' => $filePath,
'mime_type' => $file->getMimeType(),
'file_size' => $file->getSize(),
'file_extension' => $file->getClientOriginalExtension(),
'status' => AttendeeAsset::STATUS_PENDING,
'is_encrypted' => $shouldEncrypt,
'encryption_key_id' => $shouldEncrypt ? $keyId : null,
'metadata' => $this->extractMetadata($file),
]);
// Queue malware scan
ScanAttendeeAsset::dispatch($asset);
// Queue thumbnail generation for images
if ($this->isImage($file)) {
GenerateAssetThumbnail::dispatch($asset);
}
return $asset;
}
/**
* Determine if file should be encrypted
*/
protected function shouldEncrypt(?AttendeeField $field, Project $project): bool
{
// Check field-level setting
if ($field && isset($field->custom_settings['encrypt_uploads'])) {
return $field->custom_settings['encrypt_uploads'];
}
// Check project-level setting
return $project->settings['encrypt_attendee_uploads'] ?? false;
}
/**
* Extract file metadata
*/
protected function extractMetadata(UploadedFile $file): array
{
$metadata = [];
// Image metadata
if ($this->isImage($file)) {
$imageInfo = @getimagesize($file->getPathname());
if ($imageInfo) {
$metadata['width'] = $imageInfo[0];
$metadata['height'] = $imageInfo[1];
$metadata['image_type'] = $imageInfo['mime'];
}
}
// PDF metadata
if ($file->getMimeType() === 'application/pdf') {
// Could extract page count, etc.
}
return $metadata;
}
/**
* Check if file is an image
*/
protected function isImage(UploadedFile $file): bool
{
return str_starts_with($file->getMimeType(), 'image/');
}
/**
* Download asset
*/
public function download(AttendeeAsset $asset): array
{
if (!$asset->isSafe()) {
throw new \Exception('Asset is not available for download.');
}
$contents = $asset->getContents();
return [
'contents' => $contents,
'filename' => $asset->original_filename,
'mime_type' => $asset->mime_type,
];
}
/**
* Delete asset
*/
public function delete(AttendeeAsset $asset): void
{
// Delete file from storage
Storage::delete($asset->file_path);
// Delete thumbnail if exists
if ($asset->thumbnail_path) {
Storage::delete($asset->thumbnail_path);
}
// Soft delete record
$asset->delete();
}
/**
* Bulk approve assets
*/
public function bulkApprove(array $assetIds, User $user): int
{
$count = 0;
foreach ($assetIds as $id) {
$asset = AttendeeAsset::find($id);
if ($asset && $asset->needsReview()) {
$asset->approve($user);
$count++;
}
}
return $count;
}
/**
* Bulk reject assets
*/
public function bulkReject(array $assetIds, User $user, string $reason): int
{
$count = 0;
foreach ($assetIds as $id) {
$asset = AttendeeAsset::find($id);
if ($asset && $asset->status === AttendeeAsset::STATUS_PENDING) {
$asset->reject($user, $reason);
$count++;
}
}
return $count;
}
}
3. GPG Encryption Service
<?php
namespace App\Services\Security;
use App\Models\Project;
use Illuminate\Support\Facades\Cache;
class GpgEncryptionService
{
protected string $gpgHome;
public function __construct()
{
$this->gpgHome = config('services.gpg.home', '/var/www/.gnupg');
}
/**
* Encrypt data using GPG
*/
public function encrypt(string $data, string $keyId): string
{
$descriptors = [
0 => ['pipe', 'r'], // stdin
1 => ['pipe', 'w'], // stdout
2 => ['pipe', 'w'], // stderr
];
$cmd = sprintf(
'gpg --homedir %s --batch --yes --trust-model always -e -r %s',
escapeshellarg($this->gpgHome),
escapeshellarg($keyId)
);
$process = proc_open($cmd, $descriptors, $pipes);
if (!is_resource($process)) {
throw new \Exception('Failed to start GPG process');
}
fwrite($pipes[0], $data);
fclose($pipes[0]);
$encrypted = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$error = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$exitCode = proc_close($process);
if ($exitCode !== 0) {
throw new \Exception("GPG encryption failed: {$error}");
}
return $encrypted;
}
/**
* Decrypt data using GPG
*/
public function decrypt(string $data, string $keyId): string
{
$passphrase = $this->getKeyPassphrase($keyId);
$descriptors = [
0 => ['pipe', 'r'], // stdin
1 => ['pipe', 'w'], // stdout
2 => ['pipe', 'w'], // stderr
];
$cmd = sprintf(
'gpg --homedir %s --batch --yes --passphrase-fd 3 -d',
escapeshellarg($this->gpgHome)
);
// Create a pipe for passphrase
$passphraseFile = tmpfile();
fwrite($passphraseFile, $passphrase);
fseek($passphraseFile, 0);
$passphrasePath = stream_get_meta_data($passphraseFile)['uri'];
$cmd = sprintf(
'gpg --homedir %s --batch --yes --passphrase-file %s -d',
escapeshellarg($this->gpgHome),
escapeshellarg($passphrasePath)
);
$process = proc_open($cmd, $descriptors, $pipes);
if (!is_resource($process)) {
fclose($passphraseFile);
throw new \Exception('Failed to start GPG process');
}
fwrite($pipes[0], $data);
fclose($pipes[0]);
$decrypted = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$error = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$exitCode = proc_close($process);
fclose($passphraseFile);
if ($exitCode !== 0) {
throw new \Exception("GPG decryption failed: {$error}");
}
return $decrypted;
}
/**
* Get or create project encryption key
*/
public function getProjectKeyId(Project $project): string
{
$keyId = $project->settings['gpg_key_id'] ?? null;
if (!$keyId) {
$keyId = $this->generateProjectKey($project);
}
return $keyId;
}
/**
* Generate new GPG key for project
*/
protected function generateProjectKey(Project $project): string
{
$keyConfig = <<<EOF
Key-Type: RSA
Key-Length: 4096
Subkey-Type: RSA
Subkey-Length: 4096
Name-Real: Project {$project->id}
Name-Email: project-{$project->id}@gxp.local
Expire-Date: 0
%no-protection
%commit
EOF;
$configFile = tmpfile();
fwrite($configFile, $keyConfig);
fseek($configFile, 0);
$configPath = stream_get_meta_data($configFile)['uri'];
$cmd = sprintf(
'gpg --homedir %s --batch --gen-key %s 2>&1',
escapeshellarg($this->gpgHome),
escapeshellarg($configPath)
);
exec($cmd, $output, $exitCode);
fclose($configFile);
if ($exitCode !== 0) {
throw new \Exception('Failed to generate GPG key: ' . implode("\n", $output));
}
// Extract key ID
$keyId = $this->getKeyIdByEmail("project-{$project->id}@gxp.local");
// Store key ID in project settings
$project->update([
'settings' => array_merge($project->settings ?? [], [
'gpg_key_id' => $keyId,
]),
]);
return $keyId;
}
/**
* Get key ID by email
*/
protected function getKeyIdByEmail(string $email): string
{
$cmd = sprintf(
'gpg --homedir %s --list-keys --keyid-format LONG %s 2>/dev/null',
escapeshellarg($this->gpgHome),
escapeshellarg($email)
);
exec($cmd, $output);
foreach ($output as $line) {
if (preg_match('/pub\s+rsa\d+\/([A-F0-9]+)/', $line, $matches)) {
return $matches[1];
}
}
throw new \Exception("Key not found for email: {$email}");
}
/**
* Get key passphrase (from secure storage)
*/
protected function getKeyPassphrase(string $keyId): string
{
// In production, retrieve from secure vault (AWS Secrets Manager, HashiCorp Vault, etc.)
return Cache::get("gpg_passphrase_{$keyId}", '');
}
}
4. Malware Scanning Service
<?php
namespace App\Services\Security;
use App\Models\AttendeeAsset;
use Illuminate\Support\Facades\Storage;
use Socket\Raw\Factory as SocketFactory;
class MalwareScanService
{
protected string $clamavHost;
protected int $clamavPort;
public function __construct()
{
$this->clamavHost = config('services.clamav.host', '127.0.0.1');
$this->clamavPort = config('services.clamav.port', 3310);
}
/**
* Scan file for malware
*/
public function scan(AttendeeAsset $asset): array
{
// Get file contents (decrypted if necessary)
$contents = Storage::get($asset->file_path);
// If encrypted, we need the decrypted contents for scanning
if ($asset->is_encrypted) {
$contents = app(GpgEncryptionService::class)->decrypt(
$contents,
$asset->encryption_key_id
);
}
try {
$result = $this->scanWithClamav($contents);
$asset->update([
'malware_scanned' => true,
'scanned_at' => now(),
'scan_result' => $result['status'],
]);
if ($result['status'] !== 'clean') {
$asset->quarantine($result['threat'] ?? 'Unknown threat');
}
return $result;
} catch (\Exception $e) {
report($e);
$asset->update([
'malware_scanned' => true,
'scanned_at' => now(),
'scan_result' => 'scan_error',
]);
return [
'status' => 'error',
'message' => $e->getMessage(),
];
}
}
/**
* Scan content using ClamAV daemon
*/
protected function scanWithClamav(string $contents): array
{
$socket = @fsockopen($this->clamavHost, $this->clamavPort, $errno, $errstr, 30);
if (!$socket) {
throw new \Exception("Could not connect to ClamAV: {$errstr}");
}
// Send INSTREAM command
fwrite($socket, "nINSTREAM\n");
// Send file in chunks
$chunkSize = 2048;
$offset = 0;
$length = strlen($contents);
while ($offset < $length) {
$chunk = substr($contents, $offset, $chunkSize);
$chunkLength = strlen($chunk);
// Send chunk size (4 bytes, big-endian)
fwrite($socket, pack('N', $chunkLength));
fwrite($socket, $chunk);
$offset += $chunkSize;
}
// Send zero-length chunk to indicate end
fwrite($socket, pack('N', 0));
// Read response
$response = trim(fgets($socket));
fclose($socket);
// Parse response
// Format: "stream: OK" or "stream: <VIRUS_NAME> FOUND"
if (str_contains($response, 'OK')) {
return [
'status' => 'clean',
'message' => 'No threats detected',
];
}
if (preg_match('/^stream: (.+) FOUND$/', $response, $matches)) {
return [
'status' => 'infected',
'threat' => $matches[1],
'message' => "Threat detected: {$matches[1]}",
];
}
return [
'status' => 'error',
'message' => "Unexpected ClamAV response: {$response}",
];
}
/**
* Check if ClamAV is available
*/
public function isAvailable(): bool
{
try {
$socket = @fsockopen($this->clamavHost, $this->clamavPort, $errno, $errstr, 5);
if ($socket) {
fwrite($socket, "nPING\n");
$response = trim(fgets($socket));
fclose($socket);
return $response === 'PONG';
}
} catch (\Exception $e) {
// Ignore
}
return false;
}
}
5. Background Jobs
Scan Asset Job
<?php
namespace App\Jobs;
use App\Models\AttendeeAsset;
use App\Services\Security\MalwareScanService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ScanAttendeeAsset implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public int $tries = 3;
public int $backoff = 60;
public function __construct(
public AttendeeAsset $asset,
) {}
public function handle(MalwareScanService $scanService): void
{
if ($this->asset->malware_scanned) {
return; // Already scanned
}
$scanService->scan($this->asset);
}
public function failed(\Throwable $exception): void
{
$this->asset->update([
'malware_scanned' => true,
'scanned_at' => now(),
'scan_result' => 'scan_failed',
]);
report($exception);
}
}
Generate Thumbnail Job
<?php
namespace App\Jobs;
use App\Models\AttendeeAsset;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
class GenerateAssetThumbnail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct(
public AttendeeAsset $asset,
) {}
public function handle(): void
{
if (!str_starts_with($this->asset->mime_type, 'image/')) {
return;
}
if ($this->asset->thumbnail_path) {
return; // Already has thumbnail
}
// Get original image
$contents = $this->asset->getContents();
// Create thumbnail
$image = Image::make($contents);
$image->fit(200, 200);
// Generate thumbnail path
$thumbnailFilename = 'thumb_' . $this->asset->stored_filename;
$thumbnailPath = dirname($this->asset->file_path) . '/thumbnails/' . $thumbnailFilename;
// Store thumbnail (not encrypted)
Storage::put($thumbnailPath, $image->encode());
$this->asset->update([
'thumbnail_path' => $thumbnailPath,
]);
}
}
6. Admin Controller
<?php
namespace App\Http\Controllers\Admin;
use App\Models\AttendeeAsset;
use App\Models\Project;
use App\Services\Attendee\AttendeeAssetService;
use Illuminate\Http\Request;
use Inertia\Inertia;
class AttendeeAssetController extends Controller
{
public function __construct(
protected AttendeeAssetService $assetService,
) {}
/**
* List all attendee assets
*/
public function index(Request $request, Project $project)
{
$query = AttendeeAsset::where('project_id', $project->id)
->with(['attendee:id,first_name,last_name,contact_email', 'attendeeField:id,name,slug'])
->searchable($request->input('search'))
->latest();
// Status filter
if ($status = $request->input('status')) {
$query->status($status);
}
// Field filter
if ($fieldSlug = $request->input('field')) {
$query->where('field_slug', $fieldSlug);
}
$assets = $query->paginate(25);
return Inertia::render('Dashboard/Pages/Admin/Projects/AttendeeAssets/Index', [
'assets' => $assets,
'filters' => $request->only(['search', 'status', 'field']),
'statusCounts' => $this->getStatusCounts($project),
'fields' => $this->getAssetFields($project),
]);
}
/**
* Show single asset
*/
public function show(Request $request, Project $project, AttendeeAsset $asset)
{
$asset->load(['attendee', 'attendeeField', 'approvedBy', 'rejectedBy']);
return Inertia::render('Dashboard/Pages/Admin/Projects/AttendeeAssets/Show', [
'asset' => $asset,
]);
}
/**
* Approve asset
*/
public function approve(Request $request, Project $project, AttendeeAsset $asset)
{
if (!$asset->needsReview()) {
return back()->withErrors(['asset' => 'Asset cannot be approved in current state.']);
}
$asset->approve($request->user());
return back()->with('success', 'Asset approved successfully.');
}
/**
* Reject asset
*/
public function reject(Request $request, Project $project, AttendeeAsset $asset)
{
$request->validate([
'reason' => 'required|string|max:500',
]);
$asset->reject($request->user(), $request->input('reason'));
return back()->with('success', 'Asset rejected.');
}
/**
* Bulk approve
*/
public function bulkApprove(Request $request, Project $project)
{
$request->validate([
'asset_ids' => 'required|array',
'asset_ids.*' => 'integer|exists:attendee_assets,id',
]);
$count = $this->assetService->bulkApprove(
$request->input('asset_ids'),
$request->user()
);
return back()->with('success', "{$count} assets approved.");
}
/**
* Bulk reject
*/
public function bulkReject(Request $request, Project $project)
{
$request->validate([
'asset_ids' => 'required|array',
'asset_ids.*' => 'integer|exists:attendee_assets,id',
'reason' => 'required|string|max:500',
]);
$count = $this->assetService->bulkReject(
$request->input('asset_ids'),
$request->user(),
$request->input('reason')
);
return back()->with('success', "{$count} assets rejected.");
}
/**
* Download asset
*/
public function download(Request $request, Project $project, AttendeeAsset $asset)
{
$download = $this->assetService->download($asset);
return response($download['contents'])
->header('Content-Type', $download['mime_type'])
->header('Content-Disposition', "attachment; filename=\"{$download['filename']}\"");
}
/**
* Delete asset
*/
public function destroy(Request $request, Project $project, AttendeeAsset $asset)
{
$this->assetService->delete($asset);
return back()->with('success', 'Asset deleted.');
}
/**
* Get status counts for filters
*/
protected function getStatusCounts(Project $project): array
{
return [
'all' => AttendeeAsset::where('project_id', $project->id)->count(),
'pending' => AttendeeAsset::where('project_id', $project->id)->pendingReview()->count(),
'approved' => AttendeeAsset::where('project_id', $project->id)->status('approved')->count(),
'rejected' => AttendeeAsset::where('project_id', $project->id)->status('rejected')->count(),
'quarantined' => AttendeeAsset::where('project_id', $project->id)->status('quarantined')->count(),
];
}
/**
* Get fields that have assets
*/
protected function getAssetFields(Project $project): array
{
return AttendeeAsset::where('project_id', $project->id)
->whereNotNull('field_slug')
->select('field_slug')
->distinct()
->pluck('field_slug')
->toArray();
}
}
7. Frontend Components
Asset Index Page
<!-- resources/js/Dashboard/Pages/Admin/Projects/AttendeeAssets/Index.vue -->
<script setup>
import { ref, computed } from 'vue'
import { router, useForm } from '@inertiajs/vue3'
import IndexPage from '@/Components/Mod/IndexPage.vue'
import ModBadge from '@/Components/Mod/v2/Display/ModBadge.vue'
import ModButton from '@/Components/Mod/v2/Elements/ModButton.vue'
import BulkRejectModal from './Partials/BulkRejectModal.vue'
const props = defineProps({
assets: { type: Object, required: true },
filters: { type: Object, default: () => ({}) },
statusCounts: { type: Object, default: () => ({}) },
fields: { type: Array, default: () => [] },
})
const selectedAssets = ref([])
const showBulkRejectModal = ref(false)
const headers = [
{ key: 'thumbnail', label: '', width: '60px' },
{ key: 'original_filename', label: 'File Name', sortable: true },
{ key: 'attendee.full_name', label: 'Attendee' },
{ key: 'field_slug', label: 'Field' },
{ key: 'file_size', label: 'Size', sortable: true },
{ key: 'status', label: 'Status' },
{ key: 'created_at', label: 'Uploaded', sortable: true },
]
const statusOptions = [
{ value: '', label: 'All Status' },
{ value: 'pending', label: `Pending Review (${props.statusCounts.pending})` },
{ value: 'approved', label: `Approved (${props.statusCounts.approved})` },
{ value: 'rejected', label: `Rejected (${props.statusCounts.rejected})` },
{ value: 'quarantined', label: `Quarantined (${props.statusCounts.quarantined})` },
]
const getStatusColor = (status) => {
return {
pending: 'warning',
processing: 'info',
approved: 'success',
rejected: 'danger',
quarantined: 'dark',
}[status] || 'secondary'
}
const formatFileSize = (bytes) => {
if (bytes < 1024) return bytes + ' B'
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'
return (bytes / (1024 * 1024)).toFixed(1) + ' MB'
}
const bulkApprove = () => {
router.post(route('dashboard.project.attendee-assets.bulk-approve', {
project: usePage().props.project.slug,
}), {
asset_ids: selectedAssets.value,
}, {
onSuccess: () => {
selectedAssets.value = []
},
})
}
const bulkReject = (reason) => {
router.post(route('dashboard.project.attendee-assets.bulk-reject', {
project: usePage().props.project.slug,
}), {
asset_ids: selectedAssets.value,
reason,
}, {
onSuccess: () => {
selectedAssets.value = []
showBulkRejectModal.value = false
},
})
}
</script>
<template>
<IndexPage
title="Attendee Assets"
:headers="headers"
:paginated-items="assets"
:options="{
id: 'attendee-assets',
selectable: true,
searchPlaceholder: 'Search files or attendees...',
filters: [
{
key: 'status',
label: 'Status',
options: statusOptions,
},
{
key: 'field',
label: 'Field',
options: fields.map(f => ({ value: f, label: f })),
},
],
}"
v-model:selected="selectedAssets"
>
<!-- Bulk Actions -->
<template #bulk-actions>
<div v-if="selectedAssets.length > 0" class="d-flex gap-2">
<ModButton
color="success"
size="sm"
@click="bulkApprove"
>
Approve Selected ({{ selectedAssets.length }})
</ModButton>
<ModButton
color="danger"
size="sm"
outline
@click="showBulkRejectModal = true"
>
Reject Selected
</ModButton>
</div>
</template>
<!-- Custom Column Rendering -->
<template #cell-thumbnail="{ item }">
<img
v-if="item.thumbnail_url"
:src="item.thumbnail_url"
class="rounded"
style="width: 40px; height: 40px; object-fit: cover;"
/>
<div
v-else
class="bg-light rounded d-flex align-items-center justify-content-center"
style="width: 40px; height: 40px;"
>
<ModIcon :icon="getFileIcon(item.file_extension)" />
</div>
</template>
<template #cell-original_filename="{ item }">
<div>
<strong>{{ item.original_filename }}</strong>
<div class="small text-muted">{{ item.mime_type }}</div>
</div>
</template>
<template #cell-attendee.full_name="{ item }">
<a :href="route('dashboard.attendees.show', { project: $page.props.project.slug, attendee: item.attendee_id })">
{{ item.attendee?.first_name }} {{ item.attendee?.last_name }}
</a>
</template>
<template #cell-file_size="{ item }">
{{ formatFileSize(item.file_size) }}
</template>
<template #cell-status="{ item }">
<ModBadge :color="getStatusColor(item.status)">
{{ item.status_label }}
</ModBadge>
<div v-if="item.status === 'quarantined'" class="small text-danger">
{{ item.scan_result }}
</div>
</template>
<!-- Row Actions -->
<template #row-actions="{ item }">
<div class="d-flex gap-1">
<ModButton
v-if="item.status === 'pending'"
color="success"
size="sm"
outline
@click="approveAsset(item)"
>
Approve
</ModButton>
<ModButton
v-if="item.download_url"
color="primary"
size="sm"
outline
:href="item.download_url"
>
Download
</ModButton>
</div>
</template>
</IndexPage>
<BulkRejectModal
v-model="showBulkRejectModal"
:count="selectedAssets.length"
@confirm="bulkReject"
/>
</template>
8. Configuration
Config File
<?php
// config/services.php
return [
// ... other services
'clamav' => [
'host' => env('CLAMAV_HOST', '127.0.0.1'),
'port' => env('CLAMAV_PORT', 3310),
],
'gpg' => [
'home' => env('GPG_HOME', '/var/www/.gnupg'),
],
];
Environment Variables
# ClamAV Configuration
CLAMAV_HOST=127.0.0.1
CLAMAV_PORT=3310
# GPG Configuration
GPG_HOME=/var/www/.gnupg
API Endpoints
// routes/admin/dashboard.php
Route::prefix('attendee-assets')->group(function () {
Route::get('/', [AttendeeAssetController::class, 'index']);
Route::get('{asset}', [AttendeeAssetController::class, 'show']);
Route::post('{asset}/approve', [AttendeeAssetController::class, 'approve']);
Route::post('{asset}/reject', [AttendeeAssetController::class, 'reject']);
Route::delete('{asset}', [AttendeeAssetController::class, 'destroy']);
Route::get('{asset}/download', [AttendeeAssetController::class, 'download']);
Route::post('bulk-approve', [AttendeeAssetController::class, 'bulkApprove']);
Route::post('bulk-reject', [AttendeeAssetController::class, 'bulkReject']);
});
Scheduled Tasks
// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
// Process pending asset scans
$schedule->command('assets:scan-pending')
->everyFiveMinutes()
->withoutOverlapping();
// Clean up quarantined assets older than 30 days
$schedule->command('assets:cleanup-quarantined')
->daily();
// Re-scan assets that failed scanning
$schedule->command('assets:retry-failed-scans')
->hourly();
}
Artisan Commands
<?php
// app/Console/Commands/ScanPendingAssets.php
namespace App\Console\Commands;
use App\Models\AttendeeAsset;
use App\Jobs\ScanAttendeeAsset;
use Illuminate\Console\Command;
class ScanPendingAssets extends Command
{
protected $signature = 'assets:scan-pending {--limit=100}';
protected $description = 'Queue pending assets for malware scanning';
public function handle()
{
$assets = AttendeeAsset::where('malware_scanned', false)
->where('status', AttendeeAsset::STATUS_PENDING)
->limit($this->option('limit'))
->get();
foreach ($assets as $asset) {
ScanAttendeeAsset::dispatch($asset);
}
$this->info("Queued {$assets->count()} assets for scanning.");
}
}
Summary
This completes the Attendee Registration System Enhancement documentation. The full feature set includes:
- Attendee Management - Dynamic quick add forms, dropdown type selection, quick actions, navigation
- Field Builder - Suggested fields, AI translation, password config, validation builder
- Registration Forms - New form type with resumable sessions and duplicate handling
- Quiz Forms - Full quiz system with game integration and triggers
- Portal Integration - Auth attachment, form embedding, access control
- Asset Management - Searchable table, GPG encryption, ClamAV scanning, approval workflow
Each phase can be implemented independently, with Phase 1 (Attendee Management) and Phase 4 (Registration Forms) being the highest priority items.