complere story 11.1 with qa tests
This commit is contained in:
@@ -121,4 +121,17 @@ class ConsultationFactory extends Factory
|
||||
'status' => ConsultationStatus::Rejected,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a guest consultation (no user account).
|
||||
*/
|
||||
public function guest(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'user_id' => null,
|
||||
'guest_name' => fake()->name(),
|
||||
'guest_email' => fake()->unique()->safeEmail(),
|
||||
'guest_phone' => fake()->phoneNumber(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('consultations', function (Blueprint $table) {
|
||||
// Make user_id nullable for guest consultations
|
||||
$table->foreignId('user_id')->nullable()->change();
|
||||
|
||||
// Add guest fields after user_id
|
||||
$table->string('guest_name', 255)->nullable()->after('user_id');
|
||||
$table->string('guest_email', 255)->nullable()->after('guest_name');
|
||||
$table->string('guest_phone', 50)->nullable()->after('guest_email');
|
||||
|
||||
// Index for 1-per-day guest lookup performance
|
||||
$table->index('guest_email');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('consultations', function (Blueprint $table) {
|
||||
$table->dropIndex(['guest_email']);
|
||||
$table->dropColumn(['guest_name', 'guest_email', 'guest_phone']);
|
||||
// Note: Cannot safely restore NOT NULL if guest records exist
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user