Saeed Vaziry 428140b931
refactoring (#116)
- refactoring architecture
- fix incomplete ssh logs
- code editor for scripts in the app
- remove Jobs and SSHCommands
2024-03-14 20:03:43 +01:00

60 lines
1.5 KiB
PHP

<?php
namespace App\NotificationChannels;
use App\Models\NotificationChannel;
use App\NotificationChannels\Email\NotificationMail;
use App\Notifications\NotificationInterface;
use Illuminate\Support\Facades\Mail;
use Throwable;
class Email extends AbstractNotificationChannel
{
public function createRules(array $input): array
{
return [
'email' => 'required|email',
];
}
public function createData(array $input): array
{
return [
'email' => $input['email'],
];
}
public function data(): array
{
return [
'email' => $this->notificationChannel->data['email'] ?? '',
];
}
public function connect(): bool
{
try {
Mail::to($this->data()['email'])->send(
new NotificationMail(
'Connected to VitoDeploy',
'This email confirms that you have connected your email to VitoDeploy.'
)
);
} catch (Throwable) {
return false;
}
return true;
}
public function send(object $notifiable, NotificationInterface $notification): void
{
/** @var NotificationChannel $notifiable */
$this->notificationChannel = $notifiable;
$message = $notification->toEmail($notifiable);
Mail::to($this->data()['email'])->send(
new NotificationMail($message->subject, $message->render())
);
}
}