* Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * Remove old code related to notifications * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Run linters --------- Co-authored-by: Forms Dev <chirag+new@notionforms.io> Co-authored-by: Julien Nahum <julien@nahum.net>
104 lines
3.0 KiB
PHP
104 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Forms\Form;
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
class FormFactory extends Factory
|
|
{
|
|
protected $model = Form::class;
|
|
|
|
public function forWorkspace(Workspace $workspace)
|
|
{
|
|
return $this->state(function (array $attributes) use ($workspace) {
|
|
return [
|
|
'workspace_id' => $workspace->id,
|
|
];
|
|
});
|
|
}
|
|
|
|
public function forDatabase(string $databaseId)
|
|
{
|
|
return $this->state(function (array $attributes) use ($databaseId) {
|
|
return [
|
|
'database_id' => $databaseId,
|
|
];
|
|
});
|
|
}
|
|
|
|
public function withProperties(array $properties)
|
|
{
|
|
return $this->state(function (array $attributes) use ($properties) {
|
|
return [
|
|
'properties' => $properties,
|
|
];
|
|
});
|
|
}
|
|
|
|
public function createdBy(User $user)
|
|
{
|
|
return $this->state(function (array $attributes) use ($user) {
|
|
return [
|
|
'creator_id' => $user->id,
|
|
];
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function definition()
|
|
{
|
|
return [
|
|
'title' => $this->faker->text(30),
|
|
'description' => $this->faker->randomHtml(1),
|
|
'visibility' => 'public',
|
|
'theme' => $this->faker->randomElement(Form::THEMES),
|
|
'width' => $this->faker->randomElement(Form::WIDTHS),
|
|
'dark_mode' => $this->faker->randomElement(Form::DARK_MODE_VALUES),
|
|
'color' => '#3B82F6',
|
|
'hide_title' => false,
|
|
'no_branding' => false,
|
|
'uppercase_labels' => true,
|
|
'transparent_background' => false,
|
|
'submit_button_text' => 'Submit',
|
|
'editable_submissions' => false,
|
|
're_fillable' => false,
|
|
're_fill_button_text' => 'Fill Again',
|
|
'submitted_text' => '<p>Amazing, we saved your answers. Thank you for your time and have a great day!</p>',
|
|
'use_captcha' => false,
|
|
'can_be_indexed' => true,
|
|
'password' => false,
|
|
'tags' => [],
|
|
'editable_submissions_button_text' => 'Edit submission',
|
|
'confetti_on_submission' => false,
|
|
'seo_meta' => [],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Given a Notion database list of properties, format them as the front-end does:
|
|
* - Adds id
|
|
* - Adds placeholder, prefill, help
|
|
* - Adds notion_name
|
|
*/
|
|
public static function formatProperties($properties): array
|
|
{
|
|
return collect($properties)->map(function ($property) {
|
|
return array_merge($property, [
|
|
'id' => Str::uuid(),
|
|
'placeholder' => $property['name'],
|
|
'prefill' => null,
|
|
'help' => 'Please fill this input',
|
|
'notion_name' => $property['name'],
|
|
]);
|
|
})->toArray();
|
|
}
|
|
}
|