~cypheon/nextcloud-chores-app

ref: d19a6603c01e63c7545582e5ff313ef4aec0bf9f nextcloud-chores-app/lib/Db/TeamMapper.php -rw-r--r-- 601 bytes
d19a6603 — Johann Rudloff Make overdue sidebar badge dynamic, switch badges to `CounterBubble` component 10 months ago
                                                                                
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
<?php
namespace OCA\Chores\Db;

use OCP\IDBConnection;
use OCP\AppFramework\Db\QBMapper;

class TeamMapper extends QBMapper {

  public function __construct(IDBConnection $db) {
    parent::__construct($db, 'chores_teams', Team::class);
  }

  public function find(string $userId) {
    $qb = $this->db->getQueryBuilder();

    $qb->select('t.*')
       ->from($this->tableName, 't')
       ->join('t', 'chores_team_members', 'tm', 't.id = tm.team_id')
       ->where(
         $qb->expr()->eq('member_user_id', $qb->createNamedParameter($userId))
       );

    return $this->findEntity($qb);
  }

}