Completed
Push — master ( 0d4579...961bea )
by Christopher
13s
created

Group::getRolesInEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 1
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace TechWilk\Rota;
4
5
use TechWilk\Rota\Base\Group as BaseGroup;
6
7
/**
8
 * Skeleton subclass for representing a row from the 'cr_groups' table.
9
 *
10
 *
11
 *
12
 * You should add additional methods to this class to meet the
13
 * application requirements.  This class will only be generated as
14
 * long as it does not already exist in the output directory.
15
 */
16
class Group extends BaseGroup
17
{
18
    public function getLastEvent()
19
    {
20
        return EventQuery::create()
21
            ->useEventPersonQuery()
22
              ->useUserRoleQuery()
23
                ->useRoleQuery()
24
                  ->filterByGroup($this)
25
                ->endUse()
26
              ->endUse()
27
            ->endUse()
28
            ->orderByDate('desc')
29
            ->findOne();
30
    }
31
32
    public function getRolesInEvent(Event $event)
33
    {
34
        return RoleQuery::create()
35
            ->filterByGroup($this)
36
            ->useUserRoleQuery()
37
                ->useEventPersonQuery()
38
                    ->filterByEvent($event)
39
                ->endUse()
40
            ->endUse()
41
            ->orderByName()
42
            ->find();
43
    }
44
}
45