Skip to content

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.

1008 B
Raw Blame
<?php

namespace App\Livewire;

use App\Actions\Team\DeleteTeam;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Component;

class NavbarDeleteTeam extends Component
{
    use AuthorizesRequests;

    public $team;

    public function mount()
    {
        $this->team = currentTeam()->name;
    }

    public function delete($password, $selectedActions = [])
    {
        try {
            if (! verifyPasswordConfirmation($password, $this)) {
                return 'The provided password is incorrect.';
            }

            $currentTeam = currentTeam();
            $this->authorize('delete', $currentTeam);
            $newTeam = app(DeleteTeam::class)->handle($currentTeam, auth()->user());
            refreshSession($newTeam);

            return redirect()->route('team.index');
        } catch (\Throwable $e) {
            return handleError($e, $this);
        }
    }

    public function render()
    {
        return view('livewire.navbar-delete-team');
    }
}