- Add `$selectedActions = []` parameter to delete/remove methods in multiple Livewire components to support optional deletion actions - Return error message string when password verification fails instead of silent return - Return `true` on successful deletion to indicate completion - Handle selectedActions to set component properties for cascading deletions (delete_volumes, delete_networks, delete_configurations, docker_cleanup) - Add test coverage for Danger component delete functionality with password validation and selected actions handling
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Livewire\Component;
|
|
|
|
class NavbarDeleteTeam extends Component
|
|
{
|
|
public $team;
|
|
|
|
public function mount()
|
|
{
|
|
$this->team = currentTeam()->name;
|
|
}
|
|
|
|
public function delete($password, $selectedActions = [])
|
|
{
|
|
if (! verifyPasswordConfirmation($password, $this)) {
|
|
return 'The provided password is incorrect.';
|
|
}
|
|
|
|
$currentTeam = currentTeam();
|
|
$currentTeam->delete();
|
|
|
|
$currentTeam->members->each(function ($user) use ($currentTeam) {
|
|
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();
|
|
}
|
|
});
|
|
|
|
refreshSession();
|
|
|
|
return redirectRoute($this, 'team.index');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.navbar-delete-team');
|
|
}
|
|
}
|