<?php

namespace LaraBB\User\Tasks;

use Exception;
use LaraBB\User\Models\User;

/**
 * Class DestroyUserTask
 * @package LaraBB\User\Tasks
 */
class DestroyTask
{
    /**
     * DestroyUserTask constructor.
     */
    public function __construct()
    {

    }

    /**
     * @param User $user
     * @return bool|null
     * @throws Exception
     */
    public function run(User $user): ?bool
    {
        $user->groups()->detach();
        $user->profile->delete();

        return $user->delete();
    }
}
