Code Duplication    Length = 10-10 lines in 2 locations

models/Option.php 1 location

@@ 117-126 (lines=10) @@
114
                        ? OptionValue::findOrNew($value['id'])
115
                        : new OptionValue;
116
117
                if (array_key_exists('_deleted', $value) && $value['_deleted'] && $model->exists()) {
118
                    // delete the model if it has the _deleted flag
119
                    $model->delete();
120
                } else {
121
                    // otherwise update the model's values
122
                    $model->name = $value['name'];
123
                    $model->option_id = $this->id;
124
                    $model->sort_order = $value['sort_order'];
125
                    $model->save();
126
                }
127
            }
128
        }
129
    }

models/Product.php 1 location

@@ 264-273 (lines=10) @@
261
    protected function saveOptions($options)
262
    {
263
        foreach ($options as $index => $option) {
264
            if ($model = Option::find($option['id'])) {
265
                if (array_key_exists('_deleted', $option) && $option['_deleted']) {
266
                    $model->delete();
267
                } else {
268
                    $model->fill($option);
269
                    $model->product_id = $this->id;
270
                    $model->sort_order = $index;
271
                    $model->save();
272
                }
273
            }
274
        }
275
    }
276