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

51 lines
No EOL
1.3 KiB
PHP

<?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 [
'feed_id' => \App\Models\Feed::factory(),
'platform_channel_id' => \App\Models\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(\App\Models\Feed $feed): static
{
return $this->state(fn (array $attributes) => [
'feed_id' => $feed->id,
]);
}
public function forChannel(\App\Models\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,
]);
}
}