mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
init
This commit is contained in:
34
app/Http/Livewire/NotificationChannels/AddChannel.php
Normal file
34
app/Http/Livewire/NotificationChannels/AddChannel.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\NotificationChannels;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class AddChannel extends Component
|
||||
{
|
||||
public string $provider = '';
|
||||
|
||||
public string $label;
|
||||
|
||||
public string $webhook_url;
|
||||
|
||||
public string $email;
|
||||
|
||||
public function add(): void
|
||||
{
|
||||
app(\App\Actions\NotificationChannels\AddChannel::class)->add(
|
||||
auth()->user(),
|
||||
$this->all()
|
||||
);
|
||||
|
||||
$this->emitTo(KeysList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('added', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.notification-channels.add-channel');
|
||||
}
|
||||
}
|
37
app/Http/Livewire/NotificationChannels/ChannelsList.php
Normal file
37
app/Http/Livewire/NotificationChannels/ChannelsList.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\NotificationChannels;
|
||||
|
||||
use App\Models\NotificationChannel;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ChannelsList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
protected $listeners = [
|
||||
'$refresh',
|
||||
];
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$channel = NotificationChannel::query()->findOrFail($this->deleteId);
|
||||
|
||||
$channel->delete();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.notification-channels.channels-list', [
|
||||
'channels' => NotificationChannel::query()->latest()->get(),
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user