fedi-feed-router/database/factories/PlatformChannelFactory.php
myrmidex d0d81e524e
Some checks failed
CI / ci (pull_request) Failing after 26m6s
CI / ci (push) Successful in 21m12s
114 - Select channel communities from the instance instead of typing a slug
2026-08-06 00:20:49 +02:00

46 lines
1.2 KiB
PHP

<?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->unique()->numberBetween(1, 999999),
'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) => [
'name' => $communityName,
'display_name' => ucfirst($communityName),
]);
}
}