clupilot/app/database/factories/BackupFactory.php

34 lines
993 B
PHP

<?php
namespace Database\Factories;
use App\Models\Workspace;
use App\Models\Backup;
use App\Models\Site;
use Illuminate\Database\Eloquent\Factories\Factory;
class BackupFactory extends Factory
{
protected $model = Backup::class;
public function definition(): array
{
$completedAt = $this->faker->dateTimeBetween('-7 days', 'now');
return [
'workspace_id' => Workspace::factory(),
'site_id' => Site::factory(),
'type' => $this->faker->randomElement(['hourly', 'daily', 'manual', 'snapshot']),
'size_bytes' => $this->faker->numberBetween(50_000_000, 2_000_000_000),
'status' => $this->faker->randomElement(['ok', 'ok', 'ok', 'failed']),
'storage_location' => 's3://clupilot-backups',
'completed_at' => $completedAt,
];
}
public function failed(): self
{
return $this->state(['status' => 'failed']);
}
}