trypost/database/factories/AutomationFactory.php
Paulo Castellano b23ab0166e feat(automations): implement automation features and UI enhancements
- Added new automation-related routes and controllers for managing automations.
- Introduced automation nodes in the UI with distinct styles and interactions.
- Updated sidebar to include navigation for automations.
- Enhanced post creation logic to support automation metadata.
- Refactored content type and platform enums into types for better type safety.
- Added localization for automation-related terms in English, Spanish, and Portuguese.
- Improved error handling in various components to accommodate new features.
2026-05-24 09:17:19 -03:00

60 lines
1.5 KiB
PHP

<?php
namespace Database\Factories;
use App\Enums\Automation\Status;
use App\Models\Automation;
use App\Models\User;
use App\Models\Workspace;
use Illuminate\Database\Eloquent\Factories\Factory;
class AutomationFactory extends Factory
{
protected $model = Automation::class;
public function definition(): array
{
return [
'workspace_id' => Workspace::factory(),
'user_id' => User::factory(),
'name' => fake()->sentence(3),
'status' => Status::Draft,
'nodes' => [],
'connections' => [],
];
}
public function active(): static
{
return $this->state(fn () => [
'status' => Status::Active,
'activated_at' => now(),
]);
}
public function paused(): static
{
return $this->state(fn () => [
'status' => Status::Paused,
'paused_at' => now(),
]);
}
public function withScheduleTrigger(string $cron = '0 9 * * *'): static
{
return $this->state(fn () => [
'nodes' => [
[
'id' => 'trigger_1',
'type' => 'trigger',
'position' => ['x' => 0, 'y' => 0],
'data' => [
'trigger_type' => 'schedule',
'cron' => $cron,
],
],
],
'connections' => [],
]);
}
}