fedi-feed-router/database/factories/PlatformChannelFactory.php

47 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2025-07-06 01:35:59 +02:00
<?php
namespace Database\Factories;
use App\Models\Language;
use App\Models\PlatformChannel;
use App\Models\PlatformInstance;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<PlatformChannel>
*/
class PlatformChannelFactory extends Factory
{
protected $model = PlatformChannel::class;
public function definition(): array
{
return [
'platform_instance_id' => PlatformInstance::factory(),
'channel_id' => $this->faker->slug(2),
'name' => $this->faker->words(2, true),
'display_name' => $this->faker->words(2, true),
'language_id' => Language::factory(),
'description' => $this->faker->optional()->sentence(),
'is_active' => true,
];
}
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => false,
]);
}
public function community(string $name = null): static
{
$communityName = $name ?: $this->faker->word();
return $this->state(fn (array $attributes) => [
'channel_id' => strtolower($communityName),
'name' => $communityName,
'display_name' => ucfirst($communityName),
]);
}
}