Separated laravel app to its own folder (#540)
This commit is contained in:
96
api/database/factories/FormFactory.php
Normal file
96
api/database/factories/FormFactory.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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 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),
|
||||
'size' => $this->faker->randomElement(Form::SIZES),
|
||||
'border_radius' => $this->faker->randomElement(Form::BORDER_RADIUS),
|
||||
'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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Integration;
|
||||
|
||||
use App\Models\Integration\FormIntegration;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class FormIntegrationFactory extends Factory
|
||||
{
|
||||
protected $model = FormIntegration::class;
|
||||
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'integration_id' => 'i_test',
|
||||
'status' => 'active',
|
||||
'logic' => [],
|
||||
'data' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
23
api/database/factories/OAuthProviderFactory.php
Normal file
23
api/database/factories/OAuthProviderFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\OAuthProvider;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class OAuthProviderFactory extends Factory
|
||||
{
|
||||
protected $model = OAuthProvider::class;
|
||||
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'provider' => 'google',
|
||||
'provider_user_id' => 'u_test',
|
||||
'email' => 'user@example.com',
|
||||
'name' => 'user',
|
||||
'access_token' => 'ac_test',
|
||||
'refresh_token' => 're_test',
|
||||
];
|
||||
}
|
||||
}
|
||||
34
api/database/factories/UserFactory.php
Normal file
34
api/database/factories/UserFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = User::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->name,
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'hear_about_us' => 'google',
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
api/database/factories/WorkspaceFactory.php
Normal file
24
api/database/factories/WorkspaceFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Workspace>
|
||||
*/
|
||||
class WorkspaceFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->company,
|
||||
'icon' => '🧪',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user