*/ class SupportRequestFactory extends Factory { protected $model = SupportRequest::class; /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'tenant_id' => Tenant::factory(), 'initiated_by_user_id' => User::factory(), 'internal_reference' => 'SR-'.strtoupper((string) Str::ulid()), 'primary_context_type' => SupportRequest::PRIMARY_CONTEXT_TENANT, 'attachment_mode' => SupportRequest::ATTACHMENT_MODE_DIAGNOSTIC_SNAPSHOT_ATTACHED, 'severity' => SupportRequest::SEVERITY_NORMAL, 'summary' => fake()->sentence(), 'reproduction_notes' => fake()->optional()->paragraph(), 'contact_name' => fake()->name(), 'contact_email' => fake()->safeEmail(), 'context_envelope' => [ 'schema_version' => 1, 'generated_from' => 'factory', 'attachment_mode' => SupportRequest::ATTACHMENT_MODE_DIAGNOSTIC_SNAPSHOT_ATTACHED, 'primary_context' => [ 'type' => SupportRequest::PRIMARY_CONTEXT_TENANT, ], 'canonical_context' => [ 'sections' => [], ], 'diagnostic_snapshot' => [ 'sections' => [], ], 'omissions' => [], ], ]; } public function canonicalContextOnly(): static { return $this->state(fn (array $attributes): array => [ 'attachment_mode' => SupportRequest::ATTACHMENT_MODE_CANONICAL_CONTEXT_ONLY, 'context_envelope' => array_replace_recursive($attributes['context_envelope'] ?? [], [ 'attachment_mode' => SupportRequest::ATTACHMENT_MODE_CANONICAL_CONTEXT_ONLY, 'diagnostic_snapshot' => null, 'omissions' => [[ 'type' => 'diagnostic_snapshot', 'reason' => 'omitted_without_support_diagnostics_view', ]], ]), ]); } public function forOperationRun(OperationRun $operationRun): static { return $this->state(fn (): array => [ 'tenant_id' => (int) $operationRun->tenant_id, 'workspace_id' => (int) $operationRun->workspace_id, 'operation_run_id' => (int) $operationRun->getKey(), 'primary_context_type' => SupportRequest::PRIMARY_CONTEXT_OPERATION_RUN, 'context_envelope' => [ 'schema_version' => 1, 'generated_from' => 'factory', 'attachment_mode' => SupportRequest::ATTACHMENT_MODE_DIAGNOSTIC_SNAPSHOT_ATTACHED, 'primary_context' => [ 'type' => SupportRequest::PRIMARY_CONTEXT_OPERATION_RUN, 'tenant_id' => (int) $operationRun->tenant_id, 'operation_run_id' => (int) $operationRun->getKey(), ], 'canonical_context' => [ 'sections' => [], ], 'diagnostic_snapshot' => [ 'sections' => [], ], 'omissions' => [], ], ]); } }