<?php

namespace LaraBB\Group\Actions\Admin;

use Exception;
use LaraBB\Group\Tasks\DestroyTask;
use LaraBB\Group\UI\Web\Requests\Destroy;

/**
 * Class DestroyAction
 * @package LaraBB\Group\Actions\Admin
 */
class DestroyAction
{
    /**
     * @var DestroyTask
     */
    private DestroyTask $destroyGroupTask;

    /**
     * DestroyAction constructor.
     * @param DestroyTask $destroyGroupTask
     */
    public function __construct(DestroyTask $destroyGroupTask)
    {
        $this->destroyGroupTask = $destroyGroupTask;
    }

    /**
     * @param Destroy $request
     * @return bool|null
     * @throws Exception
     */
    public function run(Destroy $request): ?bool
    {
        return $this->destroyGroupTask->byUuid($request->post('uuid'));
    }
}
