lasthourcloud/app/Http/Livewire/Notifications/DiscordSettings.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2023-05-25 16:27:52 +00:00
<?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]);
}
}
2023-05-25 16:44:24 +00:00
public function sendTestNotification()
2023-05-25 16:27:52 +00:00
{
Notification::send($this->model, new DemoNotification);
}
public function render()
{
return view('livewire.notifications.discord-settings');
}
}