ForumCategoryRepository.php 964 Bytes
<?php

namespace FootyRoom\Repositories;

use Illuminate\Database\Connection;

class ForumCategoryRepository
{
    /**
     * @var \Illuminate\Database\Connection
     */
    protected $mysql;

    /**
     * Constructor.
     *
     * @param \Illuminate\Database\Connection $mysql
     */
    public function __construct(Connection $mysql)
    {
        $this->mysql = $mysql;
    }

    /**
     * Increment category post count.
     *
     * @param int $categoryId
     */
    public function incrementPostCount($categoryId)
    {
        $this->mysql

        ->table('wp_term_taxonomy')
        ->where('term_id', '=', $categoryId)
        ->increment('count');
    }

    /**
     * Decrement category post count.
     *
     * @param int $categoryId
     */
    public function decrementPostCount($categoryId)
    {
        $this->mysql

        ->table('wp_term_taxonomy')
        ->where('term_id', '=', $categoryId)
        ->decrement('count');
    }
}