51 lines
No EOL
1.2 KiB
PHP
51 lines
No EOL
1.2 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' => null,
|
|
'platform_channel_id' => null,
|
|
'keyword' => 'test keyword',
|
|
'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,
|
|
]);
|
|
}
|
|
} |