feat: delete team in cloud without subscription
This commit is contained in:
35
app/Livewire/NavbarDeleteTeam.php
Normal file
35
app/Livewire/NavbarDeleteTeam.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class NavbarDeleteTeam extends Component
|
||||||
|
{
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$currentTeam = currentTeam();
|
||||||
|
$currentTeam->delete();
|
||||||
|
|
||||||
|
$currentTeam->members->each(function ($user) use ($currentTeam) {
|
||||||
|
if ($user->id === auth()->user()->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 redirect()->route('team.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.navbar-delete-team');
|
||||||
|
}
|
||||||
|
}
|
@@ -351,6 +351,9 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@endif
|
@endif
|
||||||
|
@if (!isSubscribed() && isCloud() && auth()->user()->teams()->get()->count() > 1)
|
||||||
|
<livewire:navbar-delete-team />
|
||||||
|
@endif
|
||||||
<li>
|
<li>
|
||||||
<x-modal-input title="How can we help?">
|
<x-modal-input title="How can we help?">
|
||||||
<x-slot:content>
|
<x-slot:content>
|
||||||
@@ -380,44 +383,5 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{{-- <li>
|
|
||||||
<div class="text-xs font-semibold leading-6 text-gray-400">Your teams</div>
|
|
||||||
<ul role="list" class="mt-2 -mx-2 space-y-1">
|
|
||||||
<li>
|
|
||||||
<a href="#"
|
|
||||||
class="flex p-2 text-sm font-semibold leading-6 text-gray-700 rounded-md hover:text-indigo-600 hover:bg-gray-50 group gap-x-3">
|
|
||||||
<span
|
|
||||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-lg border text-[0.625rem] font-medium bg-white text-gray-400 border-gray-200 group-hover:border-indigo-600 group-hover:text-indigo-600">H</span>
|
|
||||||
<span class="truncate">Heroicons</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="#"
|
|
||||||
class="flex p-2 text-sm font-semibold leading-6 text-gray-700 rounded-md hover:text-indigo-600 hover:bg-gray-50 group gap-x-3">
|
|
||||||
<span
|
|
||||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-lg border text-[0.625rem] font-medium bg-white text-gray-400 border-gray-200 group-hover:border-indigo-600 group-hover:text-indigo-600">T</span>
|
|
||||||
<span class="truncate">Tailwind Labs</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="#"
|
|
||||||
class="flex p-2 text-sm font-semibold leading-6 text-gray-700 rounded-md hover:text-indigo-600 hover:bg-gray-50 group gap-x-3">
|
|
||||||
<span
|
|
||||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-lg border text-[0.625rem] font-medium bg-white text-gray-400 border-gray-200 group-hover:border-indigo-600 group-hover:text-indigo-600">W</span>
|
|
||||||
<span class="truncate">Workcation</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li class="mt-auto -mx-6">
|
|
||||||
<a href="#"
|
|
||||||
class="flex items-center px-6 py-3 text-sm font-semibold leading-6 text-gray-900 gap-x-4 hover:bg-gray-50">
|
|
||||||
<img class="w-8 h-8 rounded-full bg-gray-50"
|
|
||||||
src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
|
|
||||||
alt="">
|
|
||||||
<span class="sr-only">Your profile</span>
|
|
||||||
<span aria-hidden="true">Tom Cook</span>
|
|
||||||
</a>
|
|
||||||
</li> --}}
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
5
resources/views/livewire/navbar-delete-team.blade.php
Normal file
5
resources/views/livewire/navbar-delete-team.blade.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<div>
|
||||||
|
<x-modal-confirmation buttonFullWidth isErrorButton buttonTitle="Delete Team">
|
||||||
|
This team be deleted. It is not reversible. <br>Please think again.
|
||||||
|
</x-modal-confirmation>
|
||||||
|
</div>
|
Reference in New Issue
Block a user