<?php

namespace LaraBB\Post\Tasks;

use Exception;
use LaraBB\Post\Models\Post;

/**
 * Class DestroyPostTask
 * @package LaraBB\Post\Tasks
 */
class DestroyTask
{
    /**
     * @param Post $post
     * @return bool|null
     * @throws Exception
     */
    public function run(Post $post): ?bool
    {
        $post->users()->detach();
        $post->groups()->detach();

        return $post->delete();
    }
}
