/
dimamir
/
coolify
Обзор
Документация
Войти
/
dimamir
/
coolify
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
app/Notifications/Channels/TransactionalEmailChannel.php
45 строк
1 KB
Andras Bacsai
Refactor instanceSettings() function for improved code readability
01 окт 2024, 11:37
01 окт 2024, 11:37
8354996
Код
Авторство
О чём код?
<?php namespace App\Notifications\Channels; use App\Models\User; use Exception; use Illuminate\Mail\Message; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Mail; use Log; class TransactionalEmailChannel { public function send(User $notifiable, Notification $notification): void { $settings = instanceSettings(); if (! data_get($settings, 'smtp_enabled') && ! data_get($settings, 'resend_enabled')) { Log::info('SMTP/Resend not enabled'); return; } $email = $notifiable->email; if (! $email) { return; } $this->bootConfigs(); $mailMessage = $notification->toMail($notifiable); Mail::send( [], [], fn (Message $message) => $message ->to($email) ->subject($mailMessage->subject) ->html((string) $mailMessage->render()) ); } private function bootConfigs(): void { $type = set_transanctional_email_settings(); if (! $type) { throw new Exception('No email settings found.'); } } }