Total Complexity | 5 |
Total Lines | 113 |
Duplicated Lines | 0 % |
Coverage | 90.48% |
Changes | 0 |
1 | <?php |
||
9 | class Roles extends AbstractModel |
||
10 | { |
||
11 | /** |
||
12 | * |
||
13 | * @var integer |
||
14 | */ |
||
15 | public $id; |
||
16 | |||
17 | /** |
||
18 | * |
||
19 | * @var integer |
||
20 | */ |
||
21 | public $name; |
||
22 | |||
23 | /** |
||
24 | * |
||
25 | * @var integer |
||
26 | */ |
||
27 | public $description; |
||
28 | |||
29 | /** |
||
30 | * |
||
31 | * @var integer |
||
32 | */ |
||
33 | public $scope; |
||
34 | |||
35 | /** |
||
36 | * |
||
37 | * @var integer |
||
38 | */ |
||
39 | public $company_id; |
||
40 | |||
41 | /** |
||
42 | * |
||
43 | * @var int |
||
44 | */ |
||
45 | public $apps_id; |
||
46 | |||
47 | /** |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | public $created_at; |
||
52 | |||
53 | /** |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | public $updated_at; |
||
58 | |||
59 | /** |
||
60 | * |
||
61 | * @var integer |
||
62 | */ |
||
63 | public $is_deleted; |
||
64 | |||
65 | /** |
||
66 | * Default ACL company |
||
67 | * |
||
68 | */ |
||
69 | const DEFAULT_ACL_COMPANY_ID = 0; |
||
70 | const DEFAULT_ACL_APP_ID = 0; |
||
71 | |||
72 | /** |
||
73 | * Initialize method for model. |
||
74 | */ |
||
75 | 10 | public function initialize() |
|
76 | { |
||
77 | 10 | $this->setSource('roles'); |
|
78 | |||
79 | 10 | $this->hasMany( |
|
80 | 10 | 'roles_name', |
|
81 | 10 | 'Gewaer\Models\Roles', |
|
82 | 10 | 'name', |
|
83 | 10 | ['alias' => 'role'] |
|
84 | ); |
||
85 | 10 | } |
|
86 | |||
87 | /** |
||
88 | * Returns table name mapped in the model. |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | 10 | public function getSource(): string |
|
93 | { |
||
94 | 10 | return 'roles'; |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * Get the Role by it app name |
||
99 | * |
||
100 | * @param string $role |
||
101 | * @return Roles |
||
102 | */ |
||
103 | 6 | public static function getByAppName(string $role, BakaCompanies $company): Roles |
|
122 | ]); |
||
123 | } |
||
124 | } |
||
125 |