id(); // Null for a general enquiry, and null again if the call is later // deleted: a person who wrote in must not disappear because the // opening they answered was tidied up. $table->foreignId('call_id')->nullable() ->constrained()->nullOnDelete(); // Snapshot of what they answered, so the record still reads // correctly once the call is gone or its title is rewritten. $table->string('call_title')->nullable(); $table->string('kind', 20)->default('contribute'); $table->string('status', 20)->default('new'); $table->string('name'); $table->string('email'); $table->string('organisation')->nullable(); $table->text('message'); // Mirrors the call's own ask, so the two numbers can be compared // at a glance instead of hunting through the message. $table->unsignedTinyInteger('hours_per_week')->nullable(); $table->jsonb('links')->nullable(); // The language they wrote in — reply in the same one. $table->string('locale', 5)->default('es'); // Hashed, never raw: enough to recognise a flood coming from one // source, without this table becoming a log of visitors' IPs. $table->string('ip_hash', 64)->nullable(); // Internal side, invisible to the sender. $table->text('notes')->nullable(); $table->foreignId('handled_by')->nullable() ->constrained('users')->nullOnDelete(); $table->timestamp('handled_at')->nullable(); $table->timestamps(); $table->softDeletes(); // The inbox is read newest-unhandled-first, and deduplication // looks up by email. $table->index(['status', 'created_at']); $table->index('email'); }); } public function down(): void { Schema::dropIfExists('applications'); } };