*/ final class FormSubmissionFactory extends Factory { protected $model = FormSubmission::class; /** @return array */ public function definition(): array { return [ 'form_schema_id' => FormSchema::factory(), 'subject_type' => null, 'subject_id' => null, 'submitted_by_user_id' => null, 'status' => FormSubmissionStatus::DRAFT, 'is_test' => false, 'submitted_in_locale' => 'nl', ]; } public function submitted(): static { return $this->state(fn () => [ 'status' => FormSubmissionStatus::SUBMITTED, 'submitted_at' => now(), ]); } public function test(): static { return $this->state(fn () => ['is_test' => true]); } /** * Force a specific tenant. The observer would otherwise resolve it * from the schema parent; this state lets tests override for edge * cases (e.g. cross-org leakage scenarios in Commit 3). */ public function forOrganisation(Organisation $organisation): static { return $this->state(fn () => ['organisation_id' => $organisation->id]); } /** * Force a specific event + its organisation. Addendum Q2 contract: * any submission tied to an event also has that event's org. */ public function forEvent(Event $event): static { return $this->state(fn () => [ 'event_id' => $event->id, 'organisation_id' => $event->organisation_id, ]); } }