|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Repository; |
|
4
|
|
|
|
|
5
|
|
|
use App\Entity\Section; |
|
6
|
|
|
use App\Entity\Student; |
|
7
|
|
|
use App\Entity\Tuition; |
|
8
|
|
|
use App\Entity\TuitionGrade; |
|
9
|
|
|
use Doctrine\ORM\QueryBuilder; |
|
10
|
|
|
|
|
11
|
|
|
class TuitionGradeRepository extends AbstractTransactionalRepository implements TuitionGradeRepositoryInterface { |
|
12
|
|
|
|
|
13
|
|
|
private function createDefaultQueryBuilder(): QueryBuilder { |
|
14
|
|
|
return $this->em->createQueryBuilder() |
|
15
|
|
|
->select(['g', 't', 's', 'c']) |
|
16
|
|
|
->from(TuitionGrade::class, 'g') |
|
17
|
|
|
->leftJoin('g.category', 'c') |
|
18
|
|
|
->leftJoin('g.student', 's') |
|
19
|
|
|
->leftJoin('g.tuition', 't'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function findAllByTuition(Tuition $tuition): array { |
|
23
|
|
|
return $this->createDefaultQueryBuilder() |
|
|
|
|
|
|
24
|
|
|
->where('t.id = :tuition') |
|
25
|
|
|
->setParameter('tuition', $tuition->getId()) |
|
26
|
|
|
->getQuery() |
|
27
|
|
|
->getResult(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function findAllByStudent(Student $student, Section $section): array { |
|
31
|
|
|
return $this->createDefaultQueryBuilder() |
|
|
|
|
|
|
32
|
|
|
->leftJoin('t.section', 'sec') |
|
33
|
|
|
->where('s.id = :student') |
|
34
|
|
|
->andWhere('sec.id = :section') |
|
35
|
|
|
->setParameter('student', $student->getId()) |
|
36
|
|
|
->setParameter('section', $section->getId()) |
|
37
|
|
|
->getQuery() |
|
38
|
|
|
->getResult(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function persist(TuitionGrade $grade): void { |
|
42
|
|
|
$this->em->persist($grade); |
|
43
|
|
|
$this->flushIfNotInTransaction(); |
|
44
|
|
|
} |
|
45
|
|
|
} |