<?php

namespace LaraBB\Forum\Tasks\Forum;

use LaraBB\Forum\Models\Forum;

/**
 * Class StoreForumTask
 * @package LaraBB\Forum\Tasks
 */
class StoreTask
{
    /**
     * StoreForumTask constructor.
     * @param Forum $forum
     */
    public function __construct(private readonly Forum $forum)
    {
    }

    /**
     * @param array $data
     * @return Forum
     */
    public function run(array $data): Forum
    {
        $this->forum->category_uuid = $data['category_uuid'];
        $this->forum->created_uuid  = $data['created_uuid'];
        $this->forum->updated_uuid  = $data['updated_uuid'];
        $this->forum->title         = $data['title'];
        $this->forum->description   = $data['description'];
        $this->forum->slug          = $data['slug'];
        $this->forum->save();

        return $this->forum;
    }
}
