mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-20 06:23:23 +00:00
Extract shared settings-layout components and a dedicated team danger-zone page. Enable modal editing for security resources, polish OAuth/API-token controls, and align notification and service configuration UI with the new navigation patterns.
57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Team;
|
|
|
|
use App\Models\Team;
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Livewire\Component;
|
|
|
|
class DangerZone extends Component
|
|
{
|
|
use AuthorizesRequests;
|
|
|
|
public Team $team;
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->team = currentTeam();
|
|
}
|
|
|
|
public function delete(): mixed
|
|
{
|
|
try {
|
|
$currentTeam = currentTeam();
|
|
$this->authorize('delete', $currentTeam);
|
|
$currentTeam->members->each(function ($user) use ($currentTeam): void {
|
|
if ($user->id === Auth::id()) {
|
|
return;
|
|
}
|
|
|
|
$user->teams()->detach($currentTeam);
|
|
$session = DB::table('sessions')->where('user_id', $user->id)->first();
|
|
if ($session) {
|
|
DB::table('sessions')->where('id', $session->id)->delete();
|
|
}
|
|
});
|
|
|
|
Cache::forget('user:'.Auth::id().':team:'.$currentTeam->id);
|
|
$currentTeam->delete();
|
|
|
|
$newTeam = Auth::user()->teams()->first();
|
|
refreshSession($newTeam);
|
|
|
|
return redirect()->route('team.index');
|
|
} catch (\Throwable $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
|
|
public function render(): mixed
|
|
{
|
|
return view('livewire.team.danger-zone');
|
|
}
|
|
}
|