52 lines
No EOL
1.3 KiB
PHP
52 lines
No EOL
1.3 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\PlatformEnum;
|
|
use App\Models\PlatformAccount;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<PlatformAccount>
|
|
*/
|
|
class PlatformAccountFactory extends Factory
|
|
{
|
|
protected $model = PlatformAccount::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'platform' => PlatformEnum::LEMMY,
|
|
'instance_url' => 'https://lemmy.' . $this->faker->domainName(),
|
|
'username' => $this->faker->userName(),
|
|
'password' => 'test-password',
|
|
'settings' => [],
|
|
'is_active' => true,
|
|
'last_tested_at' => null,
|
|
'status' => 'untested',
|
|
];
|
|
}
|
|
|
|
public function inactive(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'is_active' => false,
|
|
]);
|
|
}
|
|
|
|
public function tested(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'last_tested_at' => now()->subHours(2),
|
|
'status' => 'working',
|
|
]);
|
|
}
|
|
|
|
public function failed(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'last_tested_at' => now()->subHours(2),
|
|
'status' => 'failed',
|
|
]);
|
|
}
|
|
} |