Code Duplication    Length = 25-25 lines in 2 locations

app/Repository/Traits/Message/Queue/CrudTrait.php 1 location

@@ 37-61 (lines=25) @@
34
     *
35
     * @return void
36
     */
37
    public function queue($name, Model $model, $changeBy)
38
    {
39
        // Get modified attributes
40
        $dirty = $model->getDirty();
41
        $isNew = strpos($name, 'add_') === 0;
42
43
        // Stop if nothing changed
44
        if (!$model->isDirty() && !$isNew) {
45
            return;
46
        }
47
48
        // Get the original value of the modified attributes
49
        $origin = [];
50
        foreach ($dirty as $field => $value) {
51
            $origin[$field] = $model->getOriginal($field, $value);
52
        }
53
54
        // Fill and save to message queue
55
        $fill = $this->getFillAttributes($name, $model, $changeBy, [
56
            'dirty'  => $dirty,
57
            'origin' => $origin,
58
        ]);
59
60
        return $this->fill($fill)->save();
61
    }
62
63
    /**
64
     * Insert a record into the message queue about a delete event.

app/Repository/Message/Queue/Updater.php 1 location

@@ 32-56 (lines=25) @@
29
     *
30
     * @return void
31
     */
32
    public function queue($name, Model $model, $changeBy)
33
    {
34
        // Get modified attributes
35
        $dirty = $model->getDirty();
36
        $isNew = strpos($name, 'add_') === 0;
37
38
        // Stop if nothing changed
39
        if (!$model->isDirty() && !$isNew) {
40
            return;
41
        }
42
43
        // Get the original value of the modified attributes
44
        $origin = [];
45
        foreach ($dirty as $field => $value) {
46
            $origin[$field] = $model->getOriginal($field, $value);
47
        }
48
49
        // Fill and save to message queue
50
        $fill = $this->getFillAttributes($name, $model, $changeBy, [
51
            'dirty'  => $dirty,
52
            'origin' => $origin,
53
        ]);
54
55
        return $this->model->fill($fill)->save();
56
    }
57
58
    /**
59
     * Insert a record into the message queue about a delete event.