105 lines
3.4 KiB
PHP
105 lines
3.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\User;
|
|
use App\Models\World;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<World>
|
|
*/
|
|
class WorldFactory extends Factory
|
|
{
|
|
protected $model = World::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$title = Str::title($this->faker->unique()->words(3, true));
|
|
$startsAt = Carbon::now()->subDays(5);
|
|
$endsAt = Carbon::now()->addDays(10);
|
|
|
|
return [
|
|
'title' => $title,
|
|
'slug' => Str::slug($title),
|
|
'tagline' => $this->faker->sentence(6),
|
|
'summary' => $this->faker->sentence(12),
|
|
'description' => $this->faker->paragraphs(2, true),
|
|
'theme_key' => 'summer',
|
|
'accent_color' => '#22c55e',
|
|
'accent_color_secondary' => '#0f172a',
|
|
'background_motif' => 'sunburst',
|
|
'icon_name' => 'fa-solid fa-stars',
|
|
'status' => World::STATUS_PUBLISHED,
|
|
'type' => World::TYPE_SEASONAL,
|
|
'starts_at' => $startsAt,
|
|
'ends_at' => $endsAt,
|
|
'is_featured' => false,
|
|
'accepts_submissions' => true,
|
|
'participation_mode' => World::PARTICIPATION_MODE_MANUAL_APPROVAL,
|
|
'submission_starts_at' => $startsAt->copy()->subDay(),
|
|
'submission_ends_at' => $endsAt->copy(),
|
|
'submission_note_enabled' => true,
|
|
'community_section_enabled' => true,
|
|
'allow_readd_after_removal' => true,
|
|
'is_recurring' => false,
|
|
'recurrence_key' => null,
|
|
'recurrence_rule' => null,
|
|
'edition_year' => (int) $startsAt->year,
|
|
'cta_label' => 'Explore world',
|
|
'cta_url' => '/worlds',
|
|
'badge_label' => null,
|
|
'badge_description' => null,
|
|
'badge_url' => null,
|
|
'seo_title' => $title,
|
|
'seo_description' => $this->faker->sentence(14),
|
|
'og_image_path' => null,
|
|
'related_tags_json' => [],
|
|
'section_order_json' => array_values((array) config('worlds.default_section_order', [])),
|
|
'parent_world_id' => null,
|
|
'created_by_user_id' => User::factory(),
|
|
'published_at' => Carbon::now()->subDays(10),
|
|
];
|
|
}
|
|
|
|
public function featured(): self
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'is_featured' => true,
|
|
]);
|
|
}
|
|
|
|
public function current(): self
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => World::STATUS_PUBLISHED,
|
|
'starts_at' => Carbon::now()->subDays(7),
|
|
'ends_at' => Carbon::now()->addDays(14),
|
|
'published_at' => Carbon::now()->subDays(14),
|
|
]);
|
|
}
|
|
|
|
public function upcoming(): self
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => World::STATUS_PUBLISHED,
|
|
'starts_at' => Carbon::now()->addDays(21),
|
|
'ends_at' => Carbon::now()->addDays(35),
|
|
'published_at' => Carbon::now()->subDays(2),
|
|
]);
|
|
}
|
|
|
|
public function archived(): self
|
|
{
|
|
return $this->state(fn (): array => [
|
|
'status' => World::STATUS_ARCHIVED,
|
|
'starts_at' => Carbon::now()->subDays(45),
|
|
'ends_at' => Carbon::now()->subDays(20),
|
|
'published_at' => Carbon::now()->subDays(60),
|
|
]);
|
|
}
|
|
} |