coolify/app/Livewire/Team/Invitations.php

30 lines
732 B
PHP
Raw Normal View History

2023-06-12 12:00:01 +02:00
<?php
2023-12-07 19:06:32 +01:00
namespace App\Livewire\Team;
2023-06-12 12:00:01 +02:00
use App\Models\TeamInvitation;
use Livewire\Component;
class Invitations extends Component
{
public $invitations;
2024-06-10 22:43:34 +02:00
2023-06-12 12:00:01 +02:00
protected $listeners = ['refreshInvitations'];
2023-06-12 12:00:01 +02:00
public function deleteInvitation(int $invitation_id)
{
2024-01-31 14:19:45 +01:00
$initiation_found = TeamInvitation::find($invitation_id);
2024-06-10 22:43:34 +02:00
if (! $initiation_found) {
2024-01-31 14:19:45 +01:00
return $this->dispatch('error', 'Invitation not found.');
}
$initiation_found->delete();
2023-06-12 12:00:01 +02:00
$this->refreshInvitations();
2023-12-07 19:06:32 +01:00
$this->dispatch('success', 'Invitation revoked.');
2023-06-12 12:00:01 +02:00
}
public function refreshInvitations()
{
2023-08-22 17:44:49 +02:00
$this->invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();
}
2023-06-12 12:00:01 +02:00
}