Sending e-mails and settings on Team.
This commit is contained in:
43
app/Http/Livewire/Notifications/DiscordSettings.php
Normal file
43
app/Http/Livewire/Notifications/DiscordSettings.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Notifications;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Team;
|
||||
use App\Notifications\DemoNotification;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Livewire\Component;
|
||||
|
||||
class DiscordSettings extends Component
|
||||
{
|
||||
public Team|Server $model;
|
||||
|
||||
protected $rules = [
|
||||
'model.extra_attributes.discord_webhook' => 'nullable|url',
|
||||
'model.extra_attributes.discord_active' => 'nullable|boolean',
|
||||
];
|
||||
protected $validationAttributes = [
|
||||
'model.extra_attributes.discord_webhook' => 'Discord Webhook',
|
||||
];
|
||||
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 sentTestMessage()
|
||||
{
|
||||
Notification::send($this->model, new DemoNotification);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.notifications.discord-settings');
|
||||
}
|
||||
}
|
||||
53
app/Http/Livewire/Notifications/EmailSettings.php
Normal file
53
app/Http/Livewire/Notifications/EmailSettings.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Notifications;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Team;
|
||||
use Livewire\Component;
|
||||
|
||||
class EmailSettings extends Component
|
||||
{
|
||||
public Team|Server $model;
|
||||
|
||||
protected $rules = [
|
||||
'model.extra_attributes.smtp_active' => 'nullable|boolean',
|
||||
'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.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()
|
||||
{
|
||||
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.notifications.email-settings');
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Settings;
|
||||
|
||||
use App\Models\InstanceSettings as ModelsInstanceSettings;
|
||||
use App\Notifications\TestMessage;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Livewire\Component;
|
||||
|
||||
class DiscordNotifications extends Component
|
||||
{
|
||||
public ModelsInstanceSettings $settings;
|
||||
|
||||
protected $rules = [
|
||||
'settings.extra_attributes.discord_webhook' => 'nullable|url',
|
||||
];
|
||||
protected $validationAttributes = [
|
||||
'settings.extra_attributes.discord_webhook' => 'Discord Webhook',
|
||||
];
|
||||
public function mount($settings)
|
||||
{
|
||||
//
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
$this->resetErrorBag();
|
||||
$this->validate();
|
||||
$this->settings->save();
|
||||
}
|
||||
public function sentTestMessage()
|
||||
{
|
||||
Notification::send(auth()->user(), new TestMessage);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.settings.discord-notifications');
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Settings;
|
||||
|
||||
use App\Models\InstanceSettings as ModelsInstanceSettings;
|
||||
use App\Notifications\TestMessage;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Livewire\Component;
|
||||
|
||||
class EmailNotifications extends Component
|
||||
{
|
||||
public ModelsInstanceSettings $settings;
|
||||
|
||||
protected $rules = [
|
||||
'settings.extra_attributes.smtp_host' => 'nullable',
|
||||
'settings.extra_attributes.smtp_port' => 'nullable',
|
||||
'settings.extra_attributes.smtp_encryption' => 'nullable',
|
||||
'settings.extra_attributes.smtp_username' => 'nullable',
|
||||
'settings.extra_attributes.smtp_password' => 'nullable',
|
||||
'settings.extra_attributes.smtp_timeout' => 'nullable',
|
||||
];
|
||||
protected $validationAttributes = [
|
||||
'settings.extra_attributes.smtp_host' => 'Host',
|
||||
'settings.extra_attributes.smtp_port' => 'Port',
|
||||
'settings.extra_attributes.smtp_encryption' => 'Encryption',
|
||||
'settings.extra_attributes.smtp_username' => 'Username',
|
||||
'settings.extra_attributes.smtp_password' => 'Password',
|
||||
'settings.extra_attributes.smtp_timeout' => 'Timeout',
|
||||
];
|
||||
public function mount($settings)
|
||||
{
|
||||
ray($settings);
|
||||
//
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
$this->resetErrorBag();
|
||||
$this->validate();
|
||||
$this->settings->save();
|
||||
}
|
||||
public function sentTestMessage()
|
||||
{
|
||||
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.settings.email-notifications');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user