Code Duplication    Length = 13-14 lines in 2 locations

src/models/FightersGroup.php 2 locations

@@ 94-107 (lines=14) @@
91
     *
92
     * @param $fighters
93
     */
94
    public function syncTeams($fighters)
95
    {
96
        $this->teams()->detach();
97
        foreach ($fighters as $fighter) {
98
            if ($fighter != null) {
99
                $this->teams()->attach($fighter);
100
            } else {
101
                // Insert row manually
102
                DB::table('fighters_group_team')->insertGetId(
103
                    ['team_id' => null, 'fighters_group_id' => $this->id]
104
                );
105
            }
106
        }
107
    }
108
109
    /**
110
     * Supercharge of sync Many2Many function.
@@ 115-127 (lines=13) @@
112
     *
113
     * @param $fighters
114
     */
115
    public function syncCompetitors($fighters)
116
    {
117
        $this->competitors()->detach();
118
        foreach ($fighters as $fighter) {
119
            if ($fighter != null) {
120
                $this->competitors()->attach($fighter);
121
            } else {
122
                DB::table('fighters_group_competitor')->insertGetId(
123
                    ['competitor_id' => null, 'fighters_group_id' => $this->id]
124
                );
125
            }
126
        }
127
    }
128
}
129