Code Duplication    Length = 16-16 lines in 3 locations

models/About.php 1 location

@@ 138-153 (lines=16) @@
135
     *
136
     * @return mixed
137
     */
138
    public function beforeSave($insert)
139
    {
140
        if ($this->default == 1) {
141
142
            $default = static::findOne([
143
                'default' => 1,
144
            ]);
145
146
            if (null !== $default) {
147
                $default->default = 0;
148
                $default->save();
149
            }
150
        }
151
152
        return parent::beforeSave($insert);
153
    }
154
155
    /**
156
     * Returns the default about record.

models/Contact.php 1 location

@@ 135-150 (lines=16) @@
132
     *
133
     * @return mixed
134
     */
135
    public function beforeSave($insert)
136
    {
137
        if ($this->default == 1) {
138
139
            $default = static::findOne([
140
                'default' => 1,
141
            ]);
142
143
            if (null !== $default) {
144
                $default->default = 0;
145
                $default->save();
146
            }
147
        }
148
149
        return parent::beforeSave($insert);
150
    }
151
152
    /**
153
     * @return \yii\db\ActiveQuery

models/Home.php 1 location

@@ 114-129 (lines=16) @@
111
     *
112
     * @return mixed
113
     */
114
    public function beforeSave($insert)
115
    {
116
        if ($this->default == 1) {
117
118
            $default = static::findOne([
119
                'default' => 1,
120
            ]);
121
122
            if (null !== $default) {
123
                $default->default = 0;
124
                $default->save();
125
            }
126
        }
127
128
        return parent::beforeSave($insert);
129
    }
130
131
    /**
132
     * Returns the default home record.