<?php

namespace LaraBB\Forum\Tasks\Forum;

use LaraBB\Forum\Models\Forum;

/**
 * Class UpdateForum
 * @package LaraBB\Forum\Tasks
 */
class UpdateTask
{
    /**
     * @param Forum $forum
     * @param $data
     * @return bool
     */
    public function run(Forum $forum, $data): bool
    {
        $forum->updated_uuid  = $data['updated_uuid'] ?? $forum->updated_uuid;
        $forum->lastpost_uuid = $data['lastpost_uuid'] ?? $forum->lastpost_uuid;
        $forum->category_uuid = $data['category_uuid'] ?? $forum->category_uuid;
        $forum->title         = $data['title'] ?? $forum->title;
        $forum->description   = $data['description'] ?? $forum->description;
        $forum->slug          = $data['slug'] ?? $forum->slug;
        $forum->thread_count  = $data['thread_count'] ?? $forum->thread_count;
        $forum->posting_count = $data['posting_count'] ?? $forum->posting_count;

        return $forum->save();
    }
}
