Add notification action foundation
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?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,
|
||||
'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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user