Total Complexity | 7 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class CategoryService |
||
14 | { |
||
15 | public static function getDefaultCategory(int $userId = 0) |
||
16 | { |
||
17 | $userId = $userId ?: Yii::$app->user->id; |
||
18 | return Category::find() |
||
19 | ->where(['user_id' => $userId, 'default' => Category::DEFAULT]) |
||
20 | ->orderBy(['id' => SORT_ASC]) |
||
21 | ->asArray() |
||
22 | ->one(); |
||
23 | } |
||
24 | |||
25 | public static function getAdjustCategoryId(int $userId = 0) |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param int $id |
||
36 | * @return Account|ActiveRecord|null |
||
37 | * @throws NotFoundHttpException |
||
38 | */ |
||
39 | public static function findCurrentOne(int $id) |
||
40 | { |
||
41 | if (!$model = Category::find()->where(['id' => $id, 'user_id' => \Yii::$app->user->id])->one()) { |
||
42 | throw new NotFoundHttpException('No data found'); |
||
43 | } |
||
44 | return $model; |
||
|
|||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return array |
||
49 | */ |
||
50 | public static function getCurrentMap() |
||
54 | } |
||
55 | } |
||
56 |