<?php

namespace LaraBB\Settings\UI\Web\Handlers\Admin\Prefix;

use Exception;
use Illuminate\Http\RedirectResponse;
use LaraBB\Settings\Actions\Prefix\DestroyAction;
use LaraBB\Settings\UI\Web\Requests\Prefix\Destroy;

/**
 * Class DestroyHandler
 * @package LaraBB\Settings\UI\Web\Handlers\Admin\Prefix
 */
class DestroyHandler
{
    /**
     * DestroyHandler constructor.
     * @param DestroyAction $destroyAction
     */
    public function __construct(private readonly DestroyAction $destroyAction)
    {

    }

    /**
     * @param Destroy $request
     * @return RedirectResponse
     * @throws Exception
     */
    public function __invoke(Destroy $request): RedirectResponse
    {
        return $this->destroyAction->run($request) ? $request->success() : $request->failed();
    }
}
