Files
vito/app/Providers/NotificationChannelServiceProvider.php
Saeed Vaziry 131b828807 Plugins base (#613)
* wip

* wip

* cleanup

* notification channels

* phpstan

* services

* remove server types

* refactoring

* refactoring
2025-06-14 14:35:18 +02:00

89 lines
2.3 KiB
PHP

<?php
namespace App\Providers;
use App\DTOs\DynamicField;
use App\DTOs\DynamicForm;
use App\NotificationChannels\Discord;
use App\NotificationChannels\Email;
use App\NotificationChannels\Slack;
use App\NotificationChannels\Telegram;
use App\Plugins\RegisterNotificationChannel;
use Illuminate\Support\ServiceProvider;
class NotificationChannelServiceProvider extends ServiceProvider
{
public function register(): void {}
public function boot(): void
{
$this->discord();
$this->slack();
$this->email();
$this->telegram();
}
private function discord(): void
{
RegisterNotificationChannel::make(Discord::id())
->label('Discord')
->handler(Discord::class)
->form(
DynamicForm::make([
DynamicField::make('webhook_url')
->text()
->label('Webhook URL'),
])
)
->register();
}
public function slack(): void
{
RegisterNotificationChannel::make(Slack::id())
->label('Slack')
->handler(Slack::class)
->form(
DynamicForm::make([
DynamicField::make('webhook_url')
->text()
->label('Webhook URL'),
])
)
->register();
}
private function email(): void
{
RegisterNotificationChannel::make(Email::id())
->label('Email')
->handler(Email::class)
->form(
DynamicForm::make([
DynamicField::make('email')
->text()
->label('Email address'),
])
)
->register();
}
private function telegram(): void
{
RegisterNotificationChannel::make(Telegram::id())
->label('Telegram')
->handler(Telegram::class)
->form(
DynamicForm::make([
DynamicField::make('bot_token')
->text()
->label('Bot Token'),
DynamicField::make('chat_id')
->text()
->label('Chat ID'),
]),
)
->register();
}
}