Files
KanbanGit/database/factories/NotificationActionFactory.php
T
2026-04-24 20:02:22 +00:00

60 lines
1.7 KiB
PHP

<?php
namespace Database\Factories;
use App\Enums\NotificationChannel;
use App\Enums\NotificationEventType;
use App\Models\NotificationAction;
use App\Models\Project;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<NotificationAction>
*/
class NotificationActionFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'channel' => NotificationChannel::Webhook,
'channel_configuration' => [],
'delivery_url' => 'https://hooks.'.fake()->domainName().'/kanbangit/'.fake()->uuid(),
'enabled' => true,
'event_type' => NotificationEventType::TicketStatusChanged,
'filters' => [],
'message_template' => null,
'name' => fake()->unique()->sentence(3),
'project_id' => Project::factory(),
];
}
public function discord(): static
{
return $this->state(fn (): array => [
'channel' => NotificationChannel::Discord,
'delivery_url' => 'https://discord.com/api/webhooks/'.fake()->numberBetween(100_000, 999_999).'/'.fake()->uuid(),
'message_template' => '$ticket_key moved from $status_from to $status_to by $actor_name: $url',
]);
}
public function disabled(): static
{
return $this->state(fn (): array => [
'enabled' => false,
]);
}
public function webhook(): static
{
return $this->state(fn (): array => [
'channel' => NotificationChannel::Webhook,
'message_template' => null,
]);
}
}