GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( eba618...657dae )
by
unknown
10:35
created

Slide::afterSave()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace app\models;
4
5
use devgroup\TagDependencyHelper\ActiveRecordHelper;
6
use Yii;
7
use yii\data\ActiveDataProvider;
8
9
/**
10
 * This is the model class for table "{{%slide}}".
11
 *
12
 * @property integer $id
13
 * @property integer $slider_id
14
 * @property integer $sort_order
15
 * @property string $image
16
 * @property string $link
17
 * @property string $text
18
 * @property string $custom_view_file
19
 * @property string $css_class
20
 * @property Slider|ActiveRecordHelper $slider
21
 */
22
class Slide extends \yii\db\ActiveRecord
23
{
24
    use \app\traits\FindById;
25
26
    protected function invalidateSliderTags()
27
    {
28
        $slider = $this->slider;
29
        if ($slider !== null) {
30
            $slider->invalidateTags();
31
        }
32
    }
33
34
    public function behaviors()
35
    {
36
        return [
37
            [
38
                'class' => ActiveRecordHelper::className(),
39
            ],
40
        ];
41
    }
42
    /**
43
     * @inheritdoc
44
     */
45
    public static function tableName()
46
    {
47
        return '{{%slide}}';
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53 View Code Duplication
    public function rules()
54
    {
55
        return [
56
            [['slider_id', 'sort_order', 'active'], 'integer'],
57
            [['image', 'link', 'custom_view_file', 'css_class'], 'string', 'max' => 255],
58
            [['active'], 'default', 'value'=>1],
59
            [['text'], 'string']
60
        ];
61
    }
62
63
    /**
64
     * @inheritdoc
65
     */
66
    public function attributeLabels()
67
    {
68
        return [
69
            'id' => Yii::t('app', 'ID'),
70
            'slider_id' => Yii::t('app', 'Slider ID'),
71
            'sort_order' => Yii::t('app', 'Sort Order'),
72
            'image' => Yii::t('app', 'Image'),
73
            'link' => Yii::t('app', 'Link'),
74
            'custom_view_file' => Yii::t('app', 'Custom View File'),
75
            'css_class' => Yii::t('app', 'Css Class'),
76
            'active' => Yii::t('app', 'Active'),
77
            'text' => Yii::t('app', 'Text'),
78
        ];
79
    }
80
81
    /**
82
     * Search slides
83
     * @param $params
84
     * @return ActiveDataProvider
85
     */
86 View Code Duplication
    public function search($params)
87
    {
88
        /* @var $query \yii\db\ActiveQuery */
89
        $query = static::find()
90
            ->where(['slider_id' => $this->slider_id])
91
            ->orderBy('sort_order');
92
        $dataProvider = new ActiveDataProvider(
93
            [
94
                'query' => $query,
95
                'pagination' => [
96
                    'pageSize' => 100,
97
                ],
98
            ]
99
        );
100
        if (!($this->load($params))) {
101
            return $dataProvider;
102
        }
103
        return $dataProvider;
104
    }
105
106
    /**
107
     * @return \yii\db\ActiveQuery
108
     */
109
    public function getSlider()
110
    {
111
        return $this->hasOne(Slider::class, ['id' => 'slider_id']);
112
    }
113
114
    /**
115
     * @inheritdoc
116
     */
117
    public function afterSave($insert, $changedAttributes)
118
    {
119
        parent::afterSave($insert, $changedAttributes);
120
        $this->invalidateSliderTags();
121
    }
122
123
    /**
124
     * @inheritdoc
125
     */
126
    public function afterDelete()
127
    {
128
        parent::afterDelete();
129
        $this->invalidateSliderTags();
130
    }
131
}
132