Blame view

app/Repositories/ForumCategoryRepository.php 964 Bytes
e77200db5   nologostudio.ru   Initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  <?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');
      }
  }