a lot hehe
This commit is contained in:
@@ -4,7 +4,7 @@ namespace App\Http\Livewire\Notifications;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Team;
|
||||
use App\Notifications\DemoNotification;
|
||||
use App\Notifications\TestNotification;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -13,31 +13,40 @@ class DiscordSettings extends Component
|
||||
public Team|Server $model;
|
||||
|
||||
protected $rules = [
|
||||
'model.extra_attributes.discord_webhook' => 'nullable|url',
|
||||
'model.extra_attributes.discord_active' => 'nullable|boolean',
|
||||
'model.smtp_attributes.discord_active' => 'nullable|boolean',
|
||||
'model.smtp_attributes.discord_webhook' => 'required|url',
|
||||
];
|
||||
protected $validationAttributes = [
|
||||
'model.extra_attributes.discord_webhook' => 'Discord Webhook',
|
||||
'model.smtp_attributes.discord_webhook' => 'Discord Webhook',
|
||||
];
|
||||
public function mount($model)
|
||||
{
|
||||
//
|
||||
}
|
||||
public function instantSave()
|
||||
{
|
||||
try {
|
||||
$this->submit();
|
||||
} catch (\Exception $e) {
|
||||
$this->model->smtp_attributes->discord_active = false;
|
||||
$this->addError('model.smtp_attributes.discord_webhook', $e->getMessage());
|
||||
}
|
||||
}
|
||||
private function saveModel()
|
||||
{
|
||||
$this->model->save();
|
||||
if (is_a($this->model, Team::class)) {
|
||||
session(['currentTeam' => $this->model]);
|
||||
}
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
$this->resetErrorBag();
|
||||
$this->validate();
|
||||
$this->model->save();
|
||||
if ( is_a($this->model, Team::class)) {
|
||||
session(['currentTeam' => $this->model]);
|
||||
}
|
||||
$this->saveModel();
|
||||
}
|
||||
public function sendTestNotification()
|
||||
{
|
||||
Notification::send($this->model, new DemoNotification);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.notifications.discord-settings');
|
||||
Notification::send($this->model, new TestNotification);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Http\Livewire\Notifications;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Team;
|
||||
use App\Notifications\DemoNotification;
|
||||
use App\Notifications\TestNotification;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -13,27 +13,27 @@ class EmailSettings extends Component
|
||||
public Team|Server $model;
|
||||
|
||||
protected $rules = [
|
||||
'model.extra_attributes.smtp_active' => 'nullable|boolean',
|
||||
'model.extra_attributes.from_address' => 'nullable',
|
||||
'model.extra_attributes.from_name' => 'nullable',
|
||||
'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',
|
||||
'model.smtp_attributes.smtp_active' => 'nullable|boolean',
|
||||
'model.smtp_attributes.from_address' => 'required',
|
||||
'model.smtp_attributes.from_name' => 'required',
|
||||
'model.smtp_attributes.recipients' => 'required',
|
||||
'model.smtp_attributes.smtp_host' => 'required',
|
||||
'model.smtp_attributes.smtp_port' => 'required',
|
||||
'model.smtp_attributes.smtp_encryption' => 'nullable',
|
||||
'model.smtp_attributes.smtp_username' => 'nullable',
|
||||
'model.smtp_attributes.smtp_password' => 'nullable',
|
||||
'model.smtp_attributes.smtp_timeout' => 'nullable',
|
||||
'model.smtp_attributes.test_address' => 'nullable',
|
||||
];
|
||||
protected $validationAttributes = [
|
||||
'model.extra_attributes.from_address' => 'From Address',
|
||||
'model.extra_attributes.from_name' => 'From Name',
|
||||
'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',
|
||||
'model.smtp_attributes.from_address' => 'From Address',
|
||||
'model.smtp_attributes.from_name' => 'From Name',
|
||||
'model.smtp_attributes.recipients' => 'Recipients',
|
||||
'model.smtp_attributes.smtp_host' => 'Host',
|
||||
'model.smtp_attributes.smtp_port' => 'Port',
|
||||
'model.smtp_attributes.smtp_encryption' => 'Encryption',
|
||||
'model.smtp_attributes.smtp_username' => 'Username',
|
||||
'model.smtp_attributes.smtp_password' => 'Password',
|
||||
];
|
||||
public function mount($model)
|
||||
{
|
||||
@@ -43,17 +43,17 @@ class EmailSettings extends Component
|
||||
{
|
||||
$this->resetErrorBag();
|
||||
$this->validate();
|
||||
$this->saveModel();
|
||||
}
|
||||
private function saveModel()
|
||||
{
|
||||
$this->model->save();
|
||||
if ( is_a($this->model, Team::class)) {
|
||||
if (is_a($this->model, Team::class)) {
|
||||
session(['currentTeam' => $this->model]);
|
||||
}
|
||||
}
|
||||
public function sendTestNotification()
|
||||
public function instantSave()
|
||||
{
|
||||
Notification::send($this->model, new DemoNotification);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.notifications.email-settings');
|
||||
$this->saveModel();
|
||||
}
|
||||
}
|
||||
|
||||
19
app/Http/Livewire/Notifications/Test.php
Normal file
19
app/Http/Livewire/Notifications/Test.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Notifications;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Team;
|
||||
use App\Notifications\TestNotification;
|
||||
use Livewire\Component;
|
||||
use Notification;
|
||||
|
||||
class Test extends Component
|
||||
{
|
||||
public Team|Server $model;
|
||||
public function sendTestNotification()
|
||||
{
|
||||
Notification::send($this->model, new TestNotification);
|
||||
$this->emit('saved', 'Test notification sent.');
|
||||
}
|
||||
}
|
||||
41
app/Http/Livewire/Settings/Email.php
Normal file
41
app/Http/Livewire/Settings/Email.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Settings;
|
||||
|
||||
use App\Models\InstanceSettings;
|
||||
use Livewire\Component;
|
||||
|
||||
class Email extends Component
|
||||
{
|
||||
public InstanceSettings $model;
|
||||
|
||||
protected $rules = [
|
||||
'model.extra_attributes.from_address' => 'nullable',
|
||||
'model.extra_attributes.from_name' => 'nullable',
|
||||
'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 = [
|
||||
'model.extra_attributes.from_address' => 'From Address',
|
||||
'model.extra_attributes.from_name' => 'From Name',
|
||||
'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',
|
||||
];
|
||||
public function mount($model)
|
||||
{
|
||||
//
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.settings.email');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user