Blame view

app/Repositories/WallRepository.php 976 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
52
53
  <?php
  
  namespace FootyRoom\Repositories;
  
  use FootyRoom\Core\Wall\Wall;
  use FootyRoom\Support\AutoMapper;
  use Illuminate\Database\Connection;
  
  class WallRepository
  {
      /**
       * @var \Illuminate\Database\Connection
       */
      protected $mysql;
  
      /**
       * Constructor.
       *
       * @param \Illuminate\Database\Connection $mysql
       */
      public function __construct(Connection $mysql)
      {
          $this->mysql = $mysql;
      }
  
      /**
       * Finds wall by userId.
       *
       * @param int $userId
       *
       * @return \FootyRoom\Core\Wall\Wall|null
       */
      public function findByUserId($userId)
      {
          $postDto = $this->mysql
  
          ->table('fr_users')
          ->select([
              'user_id as userId',
              'username',
          ])
          ->where('user_id', '=', $userId)
          ->first();
  
          if (!$postDto) {
              return null;
          }
  
          $post = AutoMapper::map($postDto, Wall::class);
  
          return $post;
      }
  }