<?php

namespace LaraBB\Forum\Tasks\User;

use LaraBB\Forum\Models\Forum;

/**
 * Class UpdateForumUsersTask
 * @package LaraBB\Forum\Tasks
 */
class UpdateTask
{
    /**
     * @param Forum $forum
     * @param array $data
     * @return bool
     */
    public function run(Forum $forum, array $data): bool
    {
        if(empty($data)) return true;

        $forum->users()->detach();
        $forum->users()->attach($data);

        return true;
    }
}
