<?php

namespace LaraBB\Forum\Tasks\Forum;

use Illuminate\Database\Eloquent\Collection;
use LaraBB\Forum\Models\Forum;

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

    /**
     * @param array $with
     * @return Collection|array
     */
    public function all(array $with = []): Collection|array
    {
        return $this->forum->with($with)->get();
    }

    /**
     * @param string $uuid
     * @param array $with
     * @return Forum
     */
    public function byUuid(string $uuid, array $with = []): Forum
    {
        return $this->forum->query()->with($with)->where('uuid', $uuid)->get()->first();
    }

    /**
     * @param string $slug
     * @param array $with
     * @return Forum
     */
    public function bySlug(string $slug, array $with = []): Forum
    {
        return $this->forum->query()->with($with)->where('slug', $slug)->get()->first();
    }
}
