@@ 14-46 (lines=33) @@ | ||
11 | * Class CharacterRepository |
|
12 | * @package App\Repository |
|
13 | */ |
|
14 | class CharacterRepository extends ServiceEntityRepository |
|
15 | { |
|
16 | /** |
|
17 | * CharacterRepository constructor. |
|
18 | * @param RegistryInterface $registry |
|
19 | */ |
|
20 | public function __construct(RegistryInterface $registry) |
|
21 | { |
|
22 | parent::__construct($registry, Character::class); |
|
23 | } |
|
24 | ||
25 | /** |
|
26 | * @param $qb |
|
27 | * @param string $phrase |
|
28 | * |
|
29 | * @return QueryBuilder |
|
30 | */ |
|
31 | public function findByPhrase($qb, string $phrase): QueryBuilder |
|
32 | { |
|
33 | return $qb->andWhere('name = :phrase') |
|
34 | ->setParameter('phrase', $phrase) |
|
35 | ; |
|
36 | } |
|
37 | ||
38 | public function remove(): void |
|
39 | { |
|
40 | $this->createQueryBuilder('u') |
|
41 | ->delete() |
|
42 | ->getQuery() |
|
43 | ->execute() |
|
44 | ; |
|
45 | } |
|
46 | } |
|
47 |
@@ 14-38 (lines=25) @@ | ||
11 | * Class UserRepository |
|
12 | * @package App\Repository |
|
13 | */ |
|
14 | class UserRepository extends ServiceEntityRepository |
|
15 | { |
|
16 | /** |
|
17 | * UserRepository constructor. |
|
18 | * |
|
19 | * @param RegistryInterface $registry |
|
20 | */ |
|
21 | public function __construct(RegistryInterface $registry) |
|
22 | { |
|
23 | parent::__construct($registry, User::class); |
|
24 | } |
|
25 | ||
26 | /** |
|
27 | * @param Guild $guild |
|
28 | */ |
|
29 | public function removeFromGuild(Guild $guild): void |
|
30 | { |
|
31 | $this->createQueryBuilder('u') |
|
32 | ->delete() |
|
33 | ->where('u.guild = :guild')->setParameter('guild', $guild) |
|
34 | ->getQuery() |
|
35 | ->execute() |
|
36 | ; |
|
37 | } |
|
38 | } |
|
39 |