| Conditions | 4 |
| Paths | 4 |
| Total Lines | 11 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public static function resetSettings($data) |
||
| 15 | { |
||
| 16 | foreach ($data as $row) { |
||
| 17 | $count = self::table()->where('name', $row['name'])->count(); |
||
| 18 | if (! $count) { |
||
| 19 | self::table()->insert($row); |
||
| 20 | continue; |
||
| 21 | } |
||
| 22 | if ($count > 1) { |
||
| 23 | $rowId = self::table()->where('name', $row['name'])->orderby('id', 'asc')->first()->id; |
||
| 24 | self::table()->where('name', $row['name'])->where('id', '!=', $rowId)->delete(); |
||
| 25 | } |
||
| 36 | } |