fedi-feed-router/backend/database/factories/KeywordFactory.php

51 lines
1.3 KiB
PHP
Raw Normal View History

2025-08-02 03:48:06 +02:00
<?php
namespace Database\Factories;
use App\Models\Keyword;
use Illuminate\Database\Eloquent\Factories\Factory;
class KeywordFactory extends Factory
{
protected $model = Keyword::class;
public function definition(): array
{
return [
2025-08-10 21:18:20 +02:00
'feed_id' => \App\Models\Feed::factory(),
'platform_channel_id' => \App\Models\PlatformChannel::factory(),
'keyword' => $this->faker->word(),
2025-08-04 22:10:30 +02:00
'is_active' => $this->faker->boolean(70), // 70% chance of being active
2025-08-02 03:48:06 +02:00
'created_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
'updated_at' => now(),
];
}
2025-08-04 22:10:30 +02:00
public function forFeed(\App\Models\Feed $feed): static
2025-08-02 03:48:06 +02:00
{
return $this->state(fn (array $attributes) => [
2025-08-04 22:10:30 +02:00
'feed_id' => $feed->id,
2025-08-02 03:48:06 +02:00
]);
}
2025-08-04 22:10:30 +02:00
public function forChannel(\App\Models\PlatformChannel $channel): static
2025-08-02 03:48:06 +02:00
{
return $this->state(fn (array $attributes) => [
2025-08-04 22:10:30 +02:00
'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,
2025-08-02 03:48:06 +02:00
]);
}
}