*/ final class FormSchemaFactory extends Factory { protected $model = FormSchema::class; /** @return array */ public function definition(): array { $purpose = fake()->randomElement([ FormPurpose::EVENT_REGISTRATION, FormPurpose::INCIDENT_REPORT, FormPurpose::USER_PROFILE, FormPurpose::POST_EVENT_EVALUATION, ]); $name = 'Formulier '.fake('nl_NL')->words(2, true); return [ 'organisation_id' => Organisation::factory(), 'owner_type' => null, 'owner_id' => null, 'name' => $name, 'slug' => Str::slug($name).'-'.Str::lower(Str::random(4)), 'purpose' => $purpose, 'description' => fake('nl_NL')->sentence(), 'is_published' => false, 'submission_mode' => $purpose->defaultSubmissionMode(), 'locale' => 'nl', 'snapshot_mode' => FormSchemaSnapshotMode::NEVER, 'freeze_on_submit' => false, 'section_level_submit' => false, 'auto_save_enabled' => false, 'version' => 1, ]; } public function published(): static { return $this->state(fn () => ['is_published' => true]); } public function forPurpose(FormPurpose $purpose): static { return $this->state(fn () => [ 'purpose' => $purpose, 'submission_mode' => $purpose->defaultSubmissionMode(), ]); } }