60 lines
2.0 KiB
PHP
Raw Normal View History

2023-05-25 17:27:52 +01:00
<?php
namespace App\Http\Livewire\Notifications;
use App\Models\Server;
use App\Models\Team;
2023-05-25 17:44:24 +01:00
use App\Notifications\DemoNotification;
use Illuminate\Support\Facades\Notification;
2023-05-25 17:27:52 +01:00
use Livewire\Component;
class EmailSettings extends Component
{
public Team|Server $model;
protected $rules = [
'model.extra_attributes.smtp_active' => 'nullable|boolean',
2023-05-25 17:32:23 +01:00
'model.extra_attributes.from_address' => 'nullable',
'model.extra_attributes.from_name' => 'nullable',
2023-05-25 17:27:52 +01:00
'model.extra_attributes.recipients' => 'nullable',
'model.extra_attributes.smtp_host' => 'nullable',
'model.extra_attributes.smtp_port' => 'nullable',
'model.extra_attributes.smtp_encryption' => 'nullable',
'model.extra_attributes.smtp_username' => 'nullable',
'model.extra_attributes.smtp_password' => 'nullable',
'model.extra_attributes.smtp_timeout' => 'nullable',
];
protected $validationAttributes = [
2023-05-25 17:32:23 +01:00
'model.extra_attributes.from_address' => 'From Address',
'model.extra_attributes.from_name' => 'From Name',
2023-05-25 17:27:52 +01:00
'model.extra_attributes.recipients' => 'Recipients',
'model.extra_attributes.smtp_host' => 'Host',
'model.extra_attributes.smtp_port' => 'Port',
'model.extra_attributes.smtp_encryption' => 'Encryption',
'model.extra_attributes.smtp_username' => 'Username',
'model.extra_attributes.smtp_password' => 'Password',
'model.extra_attributes.smtp_timeout' => 'Timeout',
];
public function mount($model)
{
//
}
public function submit()
{
$this->resetErrorBag();
$this->validate();
$this->model->save();
if ( is_a($this->model, Team::class)) {
session(['currentTeam' => $this->model]);
}
}
public function sendTestNotification()
{
2023-05-25 17:44:24 +01:00
Notification::send($this->model, new DemoNotification);
2023-05-25 17:27:52 +01:00
}
public function render()
{
return view('livewire.notifications.email-settings');
}
}