ForumPostQuery.php 4.7 KB
<?php

namespace FootyRoom\Queries\Post;

use FootyRoom\Queries\Comment\ViewedBy;

class ForumPostQuery
{
    use ViewedBy;

    /**
     * @var int
     */
    const LOCAL_STICKY = 1;

    /**
     * @var int
     */
    const GLOBAL_STICKY = 5;

    /**
     * Should show sticky posts?
     *
     * @var bool
     */
    protected $sticky;

    /**
     * Should show unpublished posts?
     *
     * @var bool
     */
    protected $unpublished;

    /**
     * @var string
     */
    protected $search;

    /**
     * @var string
     */
    protected $categorySlug;

    /**
     * @var int
     */
    protected $stickyLevel = 0;

    /**
     * @var int
     */
    protected $limit = 20;

    /**
     * @var int
     */
    protected $offset = 0;

    /**
     * Find discussions that involve a specific user.
     *
     * @var int
     */
    protected $withUserId;

    /**
     * Find discussions that are created by specific user.
     *
     * @var int
     */
    protected $byUserId;

    /**
     * @var string
     */
    protected $order = 'desc';

    /**
     * Constructor.
     *
     * @param string type
     */
    public function __construct($id = null)
    {
        $this->id = $id;
    }

    /**
     * Gets the value of order.
     *
     * @return string
     */
    public function getOrder()
    {
        return $this->order;
    }

    /**
     * Sets the value of order.
     *
     * @param string $order the order
     *
     * @return self
     */
    public function order($order)
    {
        $this->order = $order;

        return $this;
    }

    /**
     * Gets the Should show unpublished posts?.
     *
     * @return bool
     */
    public function getUnpublished()
    {
        return $this->unpublished;
    }

    /**
     * Gets the value of search.
     *
     * @return string
     */
    public function getSearch()
    {
        return $this->search;
    }

    /**
     * Sets the value of search.
     *
     * @param string $search
     *
     * @return self
     */
    public function search($search)
    {
        $this->search = $search;

        return $this;
    }

    /**
     * Gets the value of limit.
     *
     * @return int
     */
    public function getLimit()
    {
        return $this->limit;
    }

    /**
     * Sets the value of limit.
     *
     * @param int $limit the limit
     *
     * @return self
     */
    public function limit($limit)
    {
        $this->limit = $limit;

        return $this;
    }

    /**
     * Gets the value of offset.
     *
     * @return int
     */
    public function getOffset()
    {
        return $this->offset;
    }

    /**
     * Sets the value of offset.
     *
     * @param int $offset the offset
     *
     * @return self
     */
    public function offset($offset)
    {
        $this->offset = $offset;

        return $this;
    }

    /**
     * Gets the value of withUserId.
     *
     * @return int
     */
    public function getWithUserId()
    {
        return $this->withUserId;
    }

    /**
     * Sets the value of withUserId.
     *
     * @param int $withUserId
     *
     * @return self
     */
    public function withUserId($withUserId)
    {
        $this->withUserId = $withUserId;

        return $this;
    }

    /**
     * Gets the value of byUserId.
     *
     * @return int
     */
    public function getByUserId()
    {
        return $this->byUserId;
    }

    /**
     * Sets the value of byUserId.
     *
     * @param int $byUserId
     *
     * @return self
     */
    public function byUserId($byUserId)
    {
        $this->byUserId = $byUserId;

        return $this;
    }

    /**
     * Gets the value of sticky.
     *
     * @return bool
     */
    public function getSticky()
    {
        return $this->sticky;
    }

    /**
     * Sets the value of sticky.
     *
     * @param bool $sticky the sticky
     *
     * @return self
     */
    public function sticky($sticky)
    {
        $this->sticky = $sticky;

        return $this;
    }

    /**
     * Gets the value of categorySlug.
     *
     * @return int
     */
    public function getCategorySlug()
    {
        return $this->categorySlug;
    }

    /**
     * Sets the value of categorySlug.
     *
     * @param int $categorySlug the categorySlug
     *
     * @return self
     */
    public function categorySlug($categorySlug)
    {
        $this->categorySlug = $categorySlug;

        return $this;
    }

    /**
     * Gets the value of stickyLevel.
     *
     * @return int
     */
    public function getStickyLevel()
    {
        if ($this->categorySlug) {
            $this->stickyLevel = self::LOCAL_STICKY;
        } else {
            $this->stickyLevel = self::GLOBAL_STICKY;
        }

        return $this->stickyLevel;
    }
}