2023-02-02 15:45:17 +00:00
|
|
|
<?php
|
|
|
|
|
2023-02-06 20:16:54 +00:00
|
|
|
namespace App\Settings;
|
2023-02-02 15:45:17 +00:00
|
|
|
|
|
|
|
use Spatie\LaravelSettings\Settings;
|
|
|
|
|
|
|
|
class MailSettings extends Settings
|
|
|
|
{
|
2023-02-07 15:35:04 +00:00
|
|
|
public ?string $mail_host;
|
|
|
|
public ?int $mail_port;
|
|
|
|
public ?string $mail_username;
|
|
|
|
public ?string $mail_password;
|
|
|
|
public ?string $mail_encryption;
|
|
|
|
public ?string $mail_from_address;
|
|
|
|
public ?string $mail_from_name;
|
|
|
|
public ?string $mail_mailer;
|
2023-02-09 21:34:34 +00:00
|
|
|
|
2023-02-02 15:45:17 +00:00
|
|
|
public static function group(): string
|
|
|
|
{
|
|
|
|
return 'mail';
|
|
|
|
}
|
2023-02-03 16:38:03 +00:00
|
|
|
|
2024-04-24 08:54:06 +00:00
|
|
|
public static function encrypted(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'mail_password',
|
|
|
|
];
|
|
|
|
}
|
2023-02-07 15:35:04 +00:00
|
|
|
|
|
|
|
public function setConfig()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
config()->set('mail.mailers.smtp.host', $this->mail_host);
|
|
|
|
config()->set('mail.mailers.smtp.port', $this->mail_port);
|
|
|
|
config()->set('mail.mailers.smtp.encryption', $this->mail_encryption);
|
|
|
|
config()->set('mail.mailers.smtp.username', $this->mail_username);
|
|
|
|
config()->set('mail.mailers.smtp.password', $this->mail_password);
|
|
|
|
config()->set('mail.from.address', $this->mail_from_address);
|
|
|
|
config()->set('mail.from.name', $this->mail_from_name);
|
|
|
|
} catch (\Exception) {
|
|
|
|
}
|
|
|
|
}
|
2023-02-09 21:34:34 +00:00
|
|
|
|
2023-02-09 23:31:27 +00:00
|
|
|
/**
|
|
|
|
* Summary of validations array
|
|
|
|
* @return array<string, string>
|
|
|
|
*/
|
|
|
|
public static function getValidations()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'mail_host' => 'nullable|string',
|
|
|
|
'mail_port' => 'nullable|int',
|
|
|
|
'mail_username' => 'nullable|string',
|
|
|
|
'mail_password' => 'nullable|string',
|
|
|
|
'mail_encryption' => 'nullable|string',
|
|
|
|
'mail_from_address' => 'nullable|string',
|
|
|
|
'mail_from_name' => 'nullable|string',
|
|
|
|
'mail_mailer' => 'nullable|string',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-02-09 21:34:34 +00:00
|
|
|
/**
|
|
|
|
* Summary of optionTypes
|
|
|
|
* Only used for the settings page
|
|
|
|
* @return array<array<'type'|'label'|'description'|'options', string|bool|float|int|array<string, string>>>
|
|
|
|
*/
|
|
|
|
public static function getOptionInputData()
|
|
|
|
{
|
|
|
|
return [
|
2023-02-20 12:44:06 +00:00
|
|
|
'category_icon' => 'fas fa-envelope',
|
2023-02-09 21:34:34 +00:00
|
|
|
'mail_host' => [
|
|
|
|
'label' => 'Mail Host',
|
|
|
|
'type' => 'string',
|
|
|
|
'description' => 'The host of your mail server.',
|
|
|
|
],
|
|
|
|
'mail_port' => [
|
|
|
|
'label' => 'Mail Port',
|
2023-02-11 15:02:02 +00:00
|
|
|
'type' => 'number',
|
2023-02-09 21:34:34 +00:00
|
|
|
'description' => 'The port of your mail server.',
|
|
|
|
],
|
|
|
|
'mail_username' => [
|
|
|
|
'label' => 'Mail Username',
|
|
|
|
'type' => 'string',
|
|
|
|
'description' => 'The username of your mail server.',
|
|
|
|
],
|
|
|
|
'mail_password' => [
|
|
|
|
'label' => 'Mail Password',
|
2023-10-22 15:11:49 +00:00
|
|
|
'type' => 'password',
|
2023-02-09 21:34:34 +00:00
|
|
|
'description' => 'The password of your mail server.',
|
|
|
|
],
|
|
|
|
'mail_encryption' => [
|
|
|
|
'label' => 'Mail Encryption',
|
2023-10-22 15:11:49 +00:00
|
|
|
'type' => 'select',
|
|
|
|
'options' => [
|
|
|
|
'null' => 'None',
|
|
|
|
'tls' => 'TLS',
|
|
|
|
'ssl' => 'SSL'
|
|
|
|
],
|
2023-02-09 21:34:34 +00:00
|
|
|
'description' => 'The encryption of your mail server.',
|
|
|
|
],
|
|
|
|
'mail_from_address' => [
|
|
|
|
'label' => 'Mail From Address',
|
|
|
|
'type' => 'string',
|
|
|
|
'description' => 'The from address of your mail server.',
|
|
|
|
],
|
|
|
|
'mail_from_name' => [
|
|
|
|
'label' => 'Mail From Name',
|
|
|
|
'type' => 'string',
|
|
|
|
'description' => 'The from name of your mail server.',
|
|
|
|
],
|
|
|
|
'mail_mailer' => [
|
|
|
|
'label' => 'Mail Mailer',
|
|
|
|
'type' => 'string',
|
|
|
|
'description' => 'The mailer of your mail server.',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|