fedi-feed-router/database/factories/KeywordFactory.php
myrmidex d2919758f5
All checks were successful
CI / ci (push) Successful in 5m52s
CI / ci (pull_request) Successful in 5m46s
Build and Push Docker Image / build (push) Successful in 4m6s
Fix Pint 1.29.0 lint issues and update CI workflow
2026-03-18 20:01:25 +01:00

53 lines
1.3 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Feed;
use App\Models\Keyword;
use App\Models\PlatformChannel;
use Illuminate\Database\Eloquent\Factories\Factory;
class KeywordFactory extends Factory
{
protected $model = Keyword::class;
public function definition(): array
{
return [
'feed_id' => Feed::factory(),
'platform_channel_id' => PlatformChannel::factory(),
'keyword' => $this->faker->word(),
'is_active' => $this->faker->boolean(70), // 70% chance of being active
'created_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
'updated_at' => now(),
];
}
public function forFeed(Feed $feed): static
{
return $this->state(fn (array $attributes) => [
'feed_id' => $feed->id,
]);
}
public function forChannel(PlatformChannel $channel): static
{
return $this->state(fn (array $attributes) => [
'platform_channel_id' => $channel->id,
]);
}
public function active(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => true,
]);
}
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => false,
]);
}
}