An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Refactor deleteInvitation method in Invitations component
Andras Bacsai0147919dc470
diff --git a/app/Livewire/Team/Invitations.php b/app/Livewire/Team/Invitations.phpindex 6a32a1d161..043c4e2e83 100644--- a/app/Livewire/Team/Invitations.php+++ b/app/Livewire/Team/Invitations.php@@ -13,17 +13,18 @@ class Invitations extends Componentpublic function deleteInvitation(int $invitation_id){- $initiation_found = TeamInvitation::find($invitation_id);- if (! $initiation_found) {+ try {+ $initiation_found = TeamInvitation::ownedByCurrentTeam()->findOrFail($invitation_id);+ $initiation_found->delete();+ $this->refreshInvitations();+ $this->dispatch('success', 'Invitation revoked.');+ } catch (\Exception $e) {return $this->dispatch('error', 'Invitation not found.');}- $initiation_found->delete();- $this->refreshInvitations();- $this->dispatch('success', 'Invitation revoked.');}public function refreshInvitations(){- $this->invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();+ $this->invitations = TeamInvitation::ownedByCurrentTeam()->get();}}diff --git a/app/Models/TeamInvitation.php b/app/Models/TeamInvitation.phpindex c202710e25..0f298a829a 100644--- a/app/Models/TeamInvitation.php+++ b/app/Models/TeamInvitation.php@@ -20,6 +20,11 @@ class TeamInvitation extends Modelreturn $this->belongsTo(Team::class);}+ public static function ownedByCurrentTeam()+ {+ return TeamInvitation::whereTeamId(currentTeam()->id);+ }+public function isValid(){$createdAt = $this->created_at;