firstOrFail(); $this->authorizeWorkspace($member->workspace_id); $this->workspaceId = $member->workspace_id; $this->memberId = $memberId; $this->memberName = $member->user->name ?? ''; } public function remove(): void { WorkspaceMember::where('id', $this->memberId) ->where('workspace_id', $this->workspaceId) ->firstOrFail() ->delete(); $this->dispatch('memberRemoved', memberId: $this->memberId); $this->closeModal(); } public static function modalMaxWidth(): string { return 'sm'; } public function render(): View { return view('livewire.modals.remove-member'); } private function authorizeWorkspace(int $workspaceId): void { Workspace::where('id', $workspaceId) ->where(fn ($q) => $q ->where('owner_id', auth()->id()) ->orWhereHas('members', fn ($q) => $q->where('user_id', auth()->id())) )->firstOrFail(); } }