<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\User;
use App\Services\RoleAssignmentService;
use Illuminate\Http\RedirectResponse;

class UserDeletionController extends Controller
{
    public function __invoke(User $user, RoleAssignmentService $service): RedirectResponse
    {
        $service->delete(request()->user(), $user);

        return redirect()->route('filament.admin.resources.users.index')
            ->with('status', __('roles.deleted'));
    }
}
