Code Duplication    Length = 16-16 lines in 3 locations

models/About.php 1 location

@@ 130-145 (lines=16) @@
127
     *
128
     * @return mixed
129
     */
130
    public function beforeSave($insert)
131
    {
132
        if ($this->default == 1) {
133
134
            $default = static::findOne([
135
                'default' => 1,
136
            ]);
137
138
            if (null !== $default) {
139
                $default->default = 0;
140
                $default->save();
141
            }
142
        }
143
144
        return parent::beforeSave($insert);
145
    }
146
147
    /**
148
     * Returns the default about record.

models/Contact.php 1 location

@@ 148-163 (lines=16) @@
145
     *
146
     * @return mixed
147
     */
148
    public function beforeSave($insert)
149
    {
150
        if ($this->default == 1) {
151
152
            $default = static::findOne([
153
                'default' => 1,
154
            ]);
155
156
            if (null !== $default) {
157
                $default->default = 0;
158
                $default->save();
159
            }
160
        }
161
162
        return parent::beforeSave($insert);
163
    }
164
165
    /**
166
     * @return \yii\db\ActiveQuery

models/Home.php 1 location

@@ 105-120 (lines=16) @@
102
     *
103
     * @return mixed
104
     */
105
    public function beforeSave($insert)
106
    {
107
        if ($this->default == 1) {
108
109
            $default = static::findOne([
110
                'default' => 1,
111
            ]);
112
113
            if (null !== $default) {
114
                $default->default = 0;
115
                $default->save();
116
            }
117
        }
118
119
        return parent::beforeSave($insert);
120
    }
121
122
    /**
123
     * Returns the default home record.