<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;

class AdminAccountController extends Controller
{
    /**
     * Daftar seluruh akun SaaS (user dari registrasi / lynk.id webhook).
     */
    public function index()
    {
        $accounts = User::with('subscriptions')->latest()->get();

        return view('accounts.index', compact('accounts'));
    }

    /**
     * Hapus akun user beserta data terkait (UMKM, subscription).
     */
    public function destroy(User $account)
    {
        $email = $account->email;
        $account->delete();

        return redirect()
            ->route('accounts.index')
            ->with('success', "Akun {$email} berhasil dihapus.");
    }
}
